|
1 | 1 | ---
|
| 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 |
2 | 15 |
|
3 | 16 | - 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). |
12 | 17 | set_fact:
|
13 | 18 | libvirt_host_lineinfile_extra_rules:
|
14 | 19 | - args:
|
15 | 20 | path: "{{ libvirt_env_path }}"
|
16 | 21 | insertafter: '^#libvirtd_opts='
|
17 | 22 | regexp: '^libvirtd_opts='
|
18 |
| - line: libvirtd_opts="{{ libvirt_host_libvirtd_args }}" |
| 23 | + line: "libvirtd_opts={{ libvirt_host_libvirtd_args }}" |
19 | 24 | 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' }}" |
25 | 27 | tags: vars
|
0 commit comments