Skip to content

Commit 89a5d60

Browse files
committed
use fcqn following the ansible lint guidelines
1 parent f1bd3da commit 89a5d60

25 files changed

+469
-80
lines changed

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,93 @@ daemon. Default is `true`.
104104
`libvirt_host_install_client`: Whether to install and enable the libvirt
105105
client. Default is `true`.
106106

107+
`libvirt_host_extra_daemon_packages`: List of additional packages to install on
108+
libvirt daemon hosts.
109+
110+
`libvirt_host_extra_client_packages`: List of additional packages to install on
111+
libvirt client hosts.
112+
113+
`libvirt_host_libvirtd_conf_enabled`: Whether to configure `libvirtd.conf`.
114+
Default is `true`.
115+
116+
`libvirt_host_libvirtd_conf`: Configuration for `libvirtd.conf`. Dict mapping
117+
option names to values. Default is an empty dict.
118+
119+
`libvirt_host_qemu_conf_enabled`: Whether to configure `qemu.conf`. Default is
120+
`true`.
121+
122+
`libvirt_host_qemu_conf`: Configuration for `qemu.conf`. Dict mapping option
123+
names to values. Default is an empty dict.
124+
125+
`libvirt_host_enable_sasl_support`: Whether to enable SASL authentication
126+
support. Default is `false`.
127+
128+
`libvirt_host_sasl_conf_enabled`: Whether to configure SASL authentication
129+
(`/etc/sasl2/libvirt.conf`). Default is the same as
130+
`libvirt_host_enable_sasl_support`.
131+
132+
`libvirt_host_sasl_conf`: Configuration for SASL authentication
133+
(`/etc/sasl2/libvirt.conf`). String.
134+
135+
`libvirt_host_sasl_mech_list`: List of enabled libvirt SASL authentication
136+
mechanisms. Default is `["SCRAM-SHA-256"]` when `libvirt_host_tls_listen` is
137+
`true`, otherwise `["DIGEST-MD5"]`.
138+
139+
`libvirt_host_sasl_credentials`: List of SASL authentication credentials to
140+
create. Each item is a dict containing `username` and `password` items.
141+
Default is a single item list containing `libvirt_host_sasl_authname` and
142+
`libvirt_host_sasl_password`.
143+
144+
`libvirt_host_sasl_authname`: Username for SASL authentication. Default is
145+
`libvirt`.
146+
147+
`libvirt_host_sasl_password`: Password for SASL authentication. Default is
148+
unset.
149+
150+
`libvirt_host_sasl_auth_conf_enabled`: Whether to configure SASL authentication
151+
credentials (`/etc/libvirt/auth.conf`). Default is the same as
152+
`libvirt_host_enable_sasl_support`.
153+
154+
`libvirt_host_sasl_auth_conf`: Configuration for SASL authentication
155+
credentials (`/etc/libvirt/auth.conf`). String.
156+
157+
`libvirt_host_sasl_auth_conf_filename`: Name of file to write SASL
158+
authentication credentials to. Default is `"/etc/libvirt/auth.conf"`.
159+
160+
`libvirt_host_sasl_auth_conf_owner`: Owner of file to write SASL
161+
authentication credentials to. Default is `"root"`.
162+
163+
`libvirt_host_sasl_auth_conf_group`: Group of file to write SASL
164+
authentication credentials to. Default is `"root"`.
165+
166+
`libvirt_host_sasl_auth_conf_mode`: Mode of file to write SASL
167+
authentication credentials to. Default is `"0600"`.
168+
169+
`libvirt_host_tcp_listen`: Whether to enable the systemd TCP socket unit.
170+
Default is `false`.
171+
172+
`libvirt_host_tcp_listen_address`: Systemd TCP socket ListenStream. See man
173+
systemd.socket for format. Default is unset.
174+
175+
`libvirt_host_tls_listen`: Whether to enable the systemd TLS socket unit.
176+
Default is `false`.
177+
178+
`libvirt_host_tls_listen_address`: Systemd TLS socket ListenStream. See man
179+
systemd.socket for format. Default is unset.
180+
181+
`libvirt_host_tls_server_cert`: TLS server certificate. Default is unset.
182+
183+
`libvirt_host_tls_server_key`: TLS server key. Default is unset.
184+
185+
`libvirt_host_tls_client_cert`: TLS client certificate. Default is unset.
186+
187+
`libvirt_host_tls_client_key`: TLS client key. Default is unset.
188+
189+
`libvirt_host_tls_cacert`: TLS CA certificate. Default is unset.
190+
191+
`libvirt_host_configure_apparmor`: Whether to configure AppArmor for directory
192+
storage pools.
193+
107194
Dependencies
108195
------------
109196

defaults/main.yml

+77
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,80 @@ libvirt_host_install_daemon: true
7373

7474
# Whether to install and enable the libvirt client.
7575
libvirt_host_install_client: true
76+
77+
# List of additional packages to install on libvirt daemon hosts.
78+
libvirt_host_extra_daemon_packages: []
79+
80+
# List of additional packages to install on libvirt client hosts.
81+
libvirt_host_extra_client_packages: []
82+
83+
# Whether to configure libvirtd.conf.
84+
libvirt_host_libvirtd_conf_enabled: true
85+
# Configuration for libvirtd.conf. Dict mapping option names to values.
86+
libvirt_host_libvirtd_conf: {}
87+
88+
# Whether to configure qemu.conf.
89+
libvirt_host_qemu_conf_enabled: true
90+
# Configuration for qemu.conf. Dict mapping option names to values.
91+
libvirt_host_qemu_conf: {}
92+
93+
# Whether to enable SASL authentication support.
94+
libvirt_host_enable_sasl_support: false
95+
96+
# Whether to configure SASL authentication (/etc/sasl2/libvirt.conf).
97+
libvirt_host_sasl_conf_enabled: "{{ libvirt_host_enable_sasl_support | bool }}"
98+
# Configuration for SASL authentication (/etc/sasl2/libvirt.conf). String.
99+
libvirt_host_sasl_conf: |
100+
mech_list: {{ libvirt_host_sasl_mech_list | join(' ') }}
101+
sasldb_path: /etc/libvirt/passwd.db
102+
# List of enabled libvirt SASL authentication mechanisms.
103+
libvirt_host_sasl_mech_list:
104+
- "{{ 'SCRAM-SHA-256' if libvirt_host_tls_listen | bool else 'DIGEST-MD5' }}"
105+
106+
# List of SASL authentication credentials to create. Each item is a dict
107+
# containing "username" and "password" items.
108+
libvirt_host_sasl_credentials:
109+
- username: "{{ libvirt_host_sasl_authname }}"
110+
password: "{{ libvirt_host_sasl_password }}"
111+
# Username for SASL authentication.
112+
libvirt_host_sasl_authname: libvirt
113+
# Password for SASL authentication.
114+
libvirt_host_sasl_password:
115+
116+
# Whether to configure SASL authentication credentials (/etc/libvirt/auth.conf).
117+
libvirt_host_sasl_auth_conf_enabled: "{{ libvirt_host_enable_sasl_support | bool }}"
118+
# Configuration for SASL authentication credentials (/etc/libvirt/auth.conf). String.
119+
libvirt_host_sasl_auth_conf: |
120+
[credentials-default]
121+
authname={{ libvirt_host_sasl_authname }}
122+
password={{ libvirt_host_sasl_password }}
123+
124+
[auth-libvirt-default]
125+
credentials=default
126+
# Name of file to write SASL authentication credentials to.
127+
libvirt_host_sasl_auth_conf_filename: "/etc/libvirt/auth.conf"
128+
# Owner of file to write SASL authentication credentials to.
129+
libvirt_host_sasl_auth_conf_owner: "root"
130+
# Group of file to write SASL authentication credentials to.
131+
libvirt_host_sasl_auth_conf_group: "root"
132+
# Mode of file to write SASL authentication credentials to.
133+
libvirt_host_sasl_auth_conf_mode: "0600"
134+
135+
# Whether to enable the systemd TCP socket unit.
136+
libvirt_host_tcp_listen: false
137+
# Systemd TCP socket ListenStream. See man systemd.socket for format.
138+
libvirt_host_tcp_listen_address:
139+
140+
# Whether to enable the systemd TLS socket unit.
141+
libvirt_host_tls_listen: false
142+
# Systemd TLS socket ListenStream. See man systemd.socket for format.
143+
libvirt_host_tls_listen_address:
144+
# TLS server and client certificates.
145+
libvirt_host_tls_server_cert:
146+
libvirt_host_tls_server_key:
147+
libvirt_host_tls_client_cert:
148+
libvirt_host_tls_client_key:
149+
libvirt_host_tls_cacert:
150+
151+
# Whether to configure AppArmor for directory storage pools.
152+
libvirt_host_configure_apparmor: "{{ libvirt_host_install_daemon | bool }}"

handlers/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22

33
- name: restart libvirt
4-
service:
4+
ansible.builtin.service:
55
name: libvirtd
66
state: restarted
77
become: true
88

99
- name: reload libvirt qemu apparmor profile template
10-
command: apparmor_parser -r /etc/apparmor.d/libvirt/TEMPLATE.qemu
10+
ansible.builtin.command: apparmor_parser -r /etc/apparmor.d/libvirt/TEMPLATE.qemu
1111
become: true

molecule/default/converge.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- role: tcharl.ansible_role_libvirt_host
3131
tasks:
3232
- name: "Post converge - Install vagrant"
33-
package:
33+
ansible.builtin.package:
3434
name:
3535
- qemu
3636
- libvirt
@@ -46,27 +46,27 @@
4646
become: true
4747

4848
- name: Start libvirtd
49-
service:
49+
ansible.builtin.service:
5050
name: libvirtd
5151
state: started
5252
become: true
5353

5454
- name: Copy vagrant file
55-
copy:
55+
ansible.builtin.copy:
5656
src: Vagrantfile
5757
dest: /home/vagrant/Vagrantfile
5858
owner: vagrant
5959
group: vagrant
6060
mode: '0644'
6161

6262
- name: Execute Vagrant as daemon
63-
command:
63+
ansible.builtin.command:
6464
cmd: "daemonize -e /home/vagrant/myvmerr.log -o /home/vagrant/myvm.log -c /home/vagrant -E VAGRANT_LOG=info /usr/bin/vagrant up --provider=libvirt"
6565
chdir: /home/vagrant
6666
creates: /home/vagrant/myvm.log
6767

6868
- name: Wait until the string "auth" is in the vagrant log
69-
wait_for:
69+
ansible.builtin.wait_for:
7070
path: /home/vagrant/myvmerr.log
7171
search_regex: SSH\sis\sready
7272
timeout: 1800

molecule/default/molecule.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lint: |
1212
set -e
1313
yamllint .
1414
flake8
15-
ANSIBLE_ROLES_PATH=${MOLECULE_PROJECT_DIRECTORY}/../community ANSIBLE_COLLECTIONS_PATH=${MOLECULE_PROJECT_DIRECTORY}/../community-collections ansible-lint
15+
ANSIBLE_ROLES_PATH=${MOLECULE_PROJECT_DIRECTORY}/..:${MOLECULE_PROJECT_DIRECTORY}/../community:${ANSIBLE_ROLES_PATH} ANSIBLE_COLLECTIONS_PATH=${MOLECULE_PROJECT_DIRECTORY}/../community-collections:${ANSIBLE_COLLECTIONS_PATH} ansible-lint
1616
platforms:
1717
- name: Fedora-Molecule-libvirt-host
1818
box: fedora/35-cloud-base
Binary file not shown.
Binary file not shown.

molecule/kvm/converge.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- role: tcharl.ansible_role_libvirt_host
2727
tasks:
2828
- name: "Post converge - Install vagrant"
29-
package:
29+
ansible.builtin.package:
3030
name:
3131
- qemu
3232
- libvirt
@@ -42,27 +42,27 @@
4242
become: true
4343

4444
- name: Start libvirtd
45-
service:
45+
ansible.builtin.service:
4646
name: libvirtd
4747
state: started
4848
become: true
4949

5050
- name: Copy vagrant file
51-
copy:
51+
ansible.builtin.copy:
5252
src: Vagrantfile
5353
dest: /home/vagrant/Vagrantfile
5454
owner: vagrant
5555
group: vagrant
5656
mode: '0644'
5757

5858
- name: Execute Vagrant as daemon
59-
command:
59+
ansible.builtin.command:
6060
cmd: "daemonize -e /home/vagrant/myvmerr.log -o /home/vagrant/myvm.log -c /home/vagrant -E VAGRANT_LOG=info /usr/bin/vagrant up --provider=libvirt"
6161
chdir: /home/vagrant
6262
creates: /home/vagrant/myvm.log
6363

6464
- name: Wait until the string "auth" is in the vagrant log
65-
wait_for:
65+
ansible.builtin.wait_for:
6666
path: /home/vagrant/myvmerr.log
6767
search_regex: SSH\sis\sready
6868
timeout: 1800

tasks/client-config.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Ensure client configuration files exist
3+
ansible.builtin.template:
4+
src: "{{ item.src }}"
5+
dest: "{{ item.dest }}"
6+
owner: "{{ item.owner }}"
7+
group: "{{ item.group }}"
8+
mode: "{{ item.mode }}"
9+
become: true
10+
loop: "{{ _libvirt_client_config_files | selectattr('enabled') }}"
11+
loop_control:
12+
label: "{{ item.dest | basename }}"
13+
vars:
14+
_libvirt_client_config_files:
15+
- src: auth.conf.j2
16+
dest: "{{ libvirt_host_sasl_auth_conf_filename }}"
17+
enabled: "{{ libvirt_host_sasl_auth_conf_enabled | bool }}"
18+
owner: "{{ libvirt_host_sasl_auth_conf_owner }}"
19+
group: "{{ libvirt_host_sasl_auth_conf_group }}"
20+
mode: "{{ libvirt_host_sasl_auth_conf_mode }}"

0 commit comments

Comments
 (0)