Skip to content

Commit 28b26c8

Browse files
committed
Support masquerading on the libvirt firewall zone.
Defaults to False. May be useful in hybrid setups, where a full routing solution is not needed, and outbound only traffic is sufficient Signed-off-by: Bohdan Dobrelia <[email protected]>
1 parent 221015d commit 28b26c8

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

roles/libvirt_manager/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Used for checking if:
4141
* `cifmw_libvirt_manager_firewalld_zone_libvirt_forward`: (Bool) Enable forwarding in the libvirt firewall zone. Defaults to: `true`
4242
* `cifmw_libvirt_manager_firewalld_default_zone`: (String) Name of the default firewall zone. Defaults to `public`.
4343
* `cifmw_libvirt_manager_firewalld_default_zone_masquerade`: (Bool) Enable masquerading on the default firewall zone. Defaults to `true`.
44+
* `cifmw_libvirt_manager_firewalld_libvirt_zone_masquerade`: (Bool) Enable masquerading on the `libvirt` firewall zone. Defaults to `false`. May be useful in hybrid setups.
4445
* `cifmw_libvirt_manager_attach_dummy_interface_on_bridges`: (Bool) Attach dummy interface on bridges. Defaults to `true`.
4546
* `cifmw_libvirt_manager_default_gw_nets`: (List[String]) List of networks used as default gateway. If not set, defaults to the `cifmw_libvirt_manager_pub_net`. Read bellow for more information about that parameter.
4647
* `cifmw_libvirt_manager_vm_users`: (List[Dict]) Used to override the default list of users enabled in the vm. For its format, refers to cloud-init [documentation](https://cloudinit.readthedocs.io/en/latest/reference/modules.html#users-and-groups) about `users`. Defaults to `[]`.

roles/libvirt_manager/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ cifmw_libvirt_manager_spineleaf_setup: false
8484
cifmw_libvirt_manager_firewalld_zone_libvirt_forward: true
8585
cifmw_libvirt_manager_firewalld_default_zone: public
8686
cifmw_libvirt_manager_firewalld_default_zone_masquerade: true
87+
cifmw_libvirt_manager_firewalld_libvirt_zone_masquerade: false
8788
cifmw_libvirt_manager_attach_dummy_interface_on_bridges: true
8889
cifmw_libvirt_manager_extra_network_configuration: {}
8990

roles/libvirt_manager/tasks/clean_layout.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@
200200
immediate: true
201201
state: enabled
202202

203+
- name: Disable masquerade in firewalld libvirt zone
204+
when: cifmw_libvirt_manager_firewalld_libvirt_zone_masquerade | bool
205+
become: true
206+
ansible.posix.firewalld:
207+
masquerade: false
208+
zone: "libvirt"
209+
permanent: true
210+
immediate: true
211+
state: enabled
212+
203213
- name: Disable forward in firewalld libvirt zone
204214
become: true
205215
notify: Restart firewalld

roles/libvirt_manager/tasks/deploy_layout.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
immediate: true
2424
state: enabled
2525

26+
- name: Enable masquerading for libvirt traffic
27+
when: cifmw_libvirt_manager_firewalld_libvirt_zone_masquerade | default(false) | bool
28+
become: true
29+
ansible.posix.firewalld:
30+
masquerade: true
31+
zone: "libvirt"
32+
permanent: true
33+
immediate: true
34+
state: enabled
35+
2636
- name: Ensure firewalld is restarts
2737
ansible.builtin.meta: flush_handlers
2838

roles/libvirt_manager/tasks/ocp_layout.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@
1111
- name: Enable masquerading for public traffic
1212
when: cifmw_libvirt_manager_firewalld_default_zone_masquerade | default(true) | bool
1313
become: true
14+
notify: Restart firewalld
1415
ansible.posix.firewalld:
1516
masquerade: true
1617
zone: "{{ cifmw_libvirt_manager_firewalld_default_zone }}"
1718
permanent: true
1819
immediate: true
1920
state: enabled
2021

22+
- name: Enable masquerading for libvirt traffic
23+
when: cifmw_libvirt_manager_firewalld_libvirt_zone_masquerade | default(false) | bool
24+
become: true
25+
notify: Restart firewalld
26+
ansible.posix.firewalld:
27+
masquerade: true
28+
zone: "libvirt"
29+
permanent: true
30+
immediate: true
31+
state: enabled
32+
2133
- name: Manage virtual resources
2234
vars:
2335
cifmw_libvirt_manager_storage_pool: >-

0 commit comments

Comments
 (0)