File tree Expand file tree Collapse file tree 5 files changed +57
-10
lines changed Expand file tree Collapse file tree 5 files changed +57
-10
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,18 @@ daemon. Default is `true`.
103103` libvirt_host_install_client ` : Whether to install and enable the libvirt
104104client. Default is ` true ` .
105105
106+ ` libvirt_host_libvirtd_conf_enabled ` : Whether to configure ` libvirtd.conf ` .
107+ Default is ` true ` .
108+
109+ ` libvirt_host_libvirtd_conf ` : Configuration for ` libvirtd.conf ` . Dict mapping
110+ option names to values. Default is an empty dict.
111+
112+ ` libvirt_host_qemu_conf_enabled ` : Whether to configure ` qemu.conf ` . Default is
113+ ` true ` .
114+
115+ ` libvirt_host_qemu_conf ` : Configuration for ` qemu.conf ` . Dict mapping option
116+ names to values. Default is an empty dict.
117+
106118Dependencies
107119------------
108120
Original file line number Diff line number Diff line change @@ -73,3 +73,13 @@ libvirt_host_install_daemon: true
7373
7474# Whether to install and enable the libvirt client.
7575libvirt_host_install_client : true
76+
77+ # Whether to configure libvirtd.conf.
78+ libvirt_host_libvirtd_conf_enabled : true
79+ # Configuration for libvirtd.conf. Dict mapping option names to values.
80+ libvirt_host_libvirtd_conf : {}
81+
82+ # Whether to configure qemu.conf.
83+ libvirt_host_qemu_conf_enabled : true
84+ # Configuration for qemu.conf. Dict mapping option names to values.
85+ libvirt_host_qemu_conf : {}
Original file line number Diff line number Diff line change 11---
22# Configure services - runs after the install stage
33
4- - name : Set socket directory in libvirtd.conf
5- lineinfile :
6- path : /etc/libvirt/libvirtd.conf
7- insertafter : ' ^#unix_sock_dir ='
8- regexp : ' ^unix_sock_dir ='
9- line : unix_sock_dir = "{{ libvirt_host_socket_dir }}"
10- become : true
11- when : libvirt_host_socket_dir | length > 0
12- notify : restart libvirt
13-
144- name : Create directory for libvirt socket
155 file :
166 state : directory
3121 notify :
3222 - restart libvirt
3323
24+ - name : Ensure configuration files exist
25+ template :
26+ src : " {{ item.src }}"
27+ dest : " {{ item.dest }}"
28+ owner : root
29+ group : root
30+ mode : 0644
31+ become : true
32+ loop : " {{ _libvirt_config_files | selectattr('enabled') }}"
33+ loop_control :
34+ label : " {{ item.dest | basename }}"
35+ vars :
36+ _libvirt_config_files :
37+ - src : libvirtd.conf.j2
38+ dest : /etc/libvirt/libvirtd.conf
39+ enabled : " {{ libvirt_host_libvirtd_conf_enabled | bool }}"
40+ - src : qemu.conf.j2
41+ dest : /etc/libvirt/qemu.conf
42+ enabled : " {{ libvirt_host_qemu_conf_enabled | bool }}"
43+ notify :
44+ - restart libvirt
45+
3446- name : Flush handlers
3547 meta : flush_handlers
3648
Original file line number Diff line number Diff line change 1+ # {{ ansible_managed }}
2+ {% if libvirt_host_socket_dir | length > 0 %}
3+ unix_sock_dir = "{{ libvirt_host_socket_dir }}"
4+ {% endif %}
5+ {% for key , value in libvirt_host_libvirtd_conf .items () %}
6+ {# While the value is not JSON formatted, it is close enough - strings need to be double quoted. #}
7+ {{ key }} = {{ value | to_json }}
8+ {% endfor %}
Original file line number Diff line number Diff line change 1+ # {{ ansible_managed }}
2+ {% for key , value in libvirt_host_qemu_conf .items () %}
3+ {# While the value is not JSON formatted, it is close enough - strings need to be double quoted. #}
4+ {{ key }} = {{ value | to_json }}
5+ {% endfor %}
You can’t perform that action at this time.
0 commit comments