Skip to content

Commit e5de405

Browse files
authored
Merge pull request #14 from /issues/13
Fix for ubuntu when libvirt not installed locally
2 parents ed42550 + a12977e commit e5de405

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

tasks/post-install-Debian.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
---
2+
# On Debian >= 8 and Ubuntu >= 16.04 the libvirt-bin package has been
3+
# split into libvirt-daemon-system and libvirt-clients. They also seem
4+
# to have changed to location to enviroment file. To prevent the need
5+
# to hard code paths for every major version we determine these
6+
# dynamically. This must be done after installing the package.
7+
# You cannot guard the with_first_found with a condition without
8+
# skip being set to true. This is undeseriable so we have to
9+
# put it behind an include (a block doesn't work).
10+
- name: Check if /etc/default/libvirt-bin exists
11+
stat:
12+
path: /etc/default/libvirt-bin
13+
register: libvirt_bin_stat
14+
tags: vars
215

316
- name: Determine path to libvirt environment file
4-
# On Debian >= 8 and Ubuntu >= 16.04 the libvirt-bin package has been
5-
# split into libvirt-daemon-system and libvirt-clients. They also seem
6-
# to have changed to location to enviroment file. To prevent the need
7-
# to hard code paths for every major version we determine these
8-
# dynamically. This must be done after installing the package.
9-
# You cannot guard the with_first_found with a condition without
10-
# skip being set to true. This is undeseriable so we have to
11-
# put it behind an include (a block doesn't work).
1217
set_fact:
1318
libvirt_host_lineinfile_extra_rules:
1419
- args:
1520
path: "{{ libvirt_env_path }}"
1621
insertafter: '^#libvirtd_opts='
1722
regexp: '^libvirtd_opts='
18-
line: libvirtd_opts="{{ libvirt_host_libvirtd_args }}"
23+
line: "libvirtd_opts={{ libvirt_host_libvirtd_args }}"
1924
condition: "{{ libvirt_host_libvirtd_args != '' }}"
20-
with_first_found:
21-
- /etc/default/libvirt-bin
22-
- /etc/default/libvirtd
23-
loop_control:
24-
loop_var: libvirt_env_path
25+
vars:
26+
libvirt_env_path: "{{ '/etc/default/libvirt-bin' if libvirt_bin_stat.stat.exists else '/etc/default/libvirtd' }}"
2527
tags: vars

0 commit comments

Comments
 (0)