-
Notifications
You must be signed in to change notification settings - Fork 33
Add support for changing libvirt socket and pid path #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ec4eba7
Add support for changing libvirt socket and pid path
jovial 59ed3c4
Use default from virt module for uri if not set
jovial eb2f1f2
Remove tenks reference
jovial 0e627d0
Document the new variables
jovial 8743608
Add some whitespace to documents
jovial 49ef7ce
Improve task name
jovial d3ec463
Add debian support for custom socket path and pid path
jovial e2b1447
whitespace fixup
jovial 01e4c73
remove spurious notify
jovial 9f5ca24
Flush handlers
jovial 5ed8d57
Correct task name
jovial de551ac
Fix paths for modern Debian systems
jovial c394cb9
Fixup Ubuntu support for connection URI
jovial 3a8f08f
Variable name had changed
jovial ec1b0f6
Address code review comments
jovial 665e047
Ensure libvirtd service is started.
jovial 5034cc9
Merge branch 'master' into feature/socket_path
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
|
||
- name: restart libvirt | ||
service: | ||
name: libvirtd | ||
state: restarted | ||
become: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# Configure services - runs after the install stage | ||
|
||
- name: Set socket directory in libvirtd.conf | ||
lineinfile: | ||
path: /etc/libvirt/libvirtd.conf | ||
insertafter: '^#unix_sock_dir =' | ||
regexp: '^unix_sock_dir =' | ||
line: unix_sock_dir = "{{ libvirt_host_socket_dir }}" | ||
become: true | ||
when: libvirt_host_socket_dir != "" | ||
notify: restart libvirt | ||
|
||
- name: Create directory for libvirt socket | ||
file: | ||
state: directory | ||
path: "{{ libvirt_host_socket_dir }}" | ||
owner: root | ||
group: root | ||
mode: 0755 | ||
become: true | ||
when: libvirt_host_socket_dir != "" | ||
|
||
- name: Process lineinfile rules | ||
lineinfile: "{{ rule.args }}" | ||
become: true | ||
loop: "{{ libvirt_host_lineinfile_extra_rules | default([]) }}" | ||
loop_control: | ||
loop_var: rule | ||
when: rule.condition | ||
notify: | ||
- restart libvirt | ||
|
||
- name: Flush handlers | ||
meta: flush_handlers | ||
|
||
- name: Ensure the libvirt daemon is started and enabled | ||
service: | ||
name: libvirtd | ||
state: started | ||
enabled: yes | ||
become: True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
--- | ||
- include: prelude.yml | ||
- include: validate.yml | ||
- include: install.yml | ||
- name: Run post-install stage | ||
include: "{{ post_install_path }}" | ||
with_first_found: | ||
- files: | ||
- post-install-{{ ansible_distribution }}.yml | ||
- post-install-{{ ansible_os_family }}.yml | ||
skip: true | ||
loop_control: | ||
loop_var: post_install_path | ||
- include: config.yml | ||
- include: pools.yml | ||
- include: networks.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
|
||
- name: Determine path to libvirt environment file | ||
# On Debian >= 8 and Ubuntu >= 16.04 the libvirt-bin package has been | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do have this condition elsewhere, so presumably we could extract it into a variable and set the path based on the variable. This works though. |
||
# split into libvirt-daemon-system and libvirt-clients. They also seem | ||
# to have changed to location to enviroment file. To prevent the need | ||
# to hard code paths for every major version we determine these | ||
# dynamically. This must be done after installing the package. | ||
# You cannot guard the with_first_found with a condition without | ||
# skip being set to true. This is undeseriable so we have to | ||
# put it behind an include (a block doesn't work). | ||
set_fact: | ||
libvirt_host_lineinfile_extra_rules: | ||
- args: | ||
path: "{{ libvirt_env_path }}" | ||
insertafter: '^#libvirtd_opts=' | ||
regexp: '^libvirtd_opts=' | ||
line: libvirtd_opts="{{ libvirt_host_libvirtd_args }}" | ||
condition: "{{ libvirt_host_libvirtd_args != '' }}" | ||
with_first_found: | ||
- /etc/default/libvirt-bin | ||
- /etc/default/libvirtd | ||
loop_control: | ||
loop_var: libvirt_env_path | ||
tags: vars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
# This file is intended to be included at the beginning of a playbook. | ||
|
||
- name: gather os specific variables | ||
include_vars: "{{ item }}" | ||
with_first_found: | ||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version}}.yml" | ||
- "{{ ansible_distribution }}.yml" | ||
- "{{ ansible_os_family }}.yml" | ||
tags: vars |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
--- | ||
# List of libvirt package dependencies. | ||
libvirt_host_libvirt_packages_default: | ||
- libvirt-bin | ||
# List of package dependencies common to all Debian distributions | ||
libvirt_host_libvirt_packages_common: | ||
- qemu-kvm | ||
- python-libvirt | ||
- python-lxml | ||
|
||
# Package that contains the libvirt daemon | ||
libvirt_host_libvirt_packages_libvirt_daemon: >- | ||
{%- if (ansible_distribution == "Ubuntu" and | ||
ansible_distribution_major_version is version_compare('16.04', '<')) or | ||
(ansible_distribution == "Debian" and | ||
ansible_distribution_major_version is version_compare('8', '<')) -%} | ||
libvirt-bin | ||
{%- else -%} | ||
libvirt-daemon-system | ||
{%- endif -%} | ||
|
||
# Packages that are only necessary if you require EFI support | ||
libvirt_host_packages_efi: | ||
- ovmf | ||
|
||
# List of all packages to install | ||
libvirt_host_libvirt_packages: > | ||
{{ libvirt_host_libvirt_packages_default + | ||
{{ libvirt_host_libvirt_packages_common + [libvirt_host_libvirt_packages_libvirt_daemon] + | ||
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique | ||
}} | ||
|
||
# These are passed to the lineinfile module to customize configuration files | ||
libvirt_host_lineinfile_extra_rules: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.