Skip to content

Commit

Permalink
Migrate ansible filters from netcommon to utils
Browse files Browse the repository at this point in the history
The netcommon filters will stop working soon, they've been migrated
to the utils module.
  • Loading branch information
elfosardo committed Jan 15, 2025
1 parent 08911be commit 8b0d282
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions vm-setup/roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ provisioning_network_nat:
- name: provisioning
bridge: provisioning
forward_mode: nat
address_v4: "{{ provisioning_network_cidr_v4|nthhost(1)|default('', true) }}"
netmask_v4: "{{ provisioning_network_cidr_v4|ipaddr('netmask') }}"
address_v4: "{{ provisioning_network_cidr_v4|ansible.utils.nthhost(1)|default('', true) }}"
netmask_v4: "{{ provisioning_network_cidr_v4|ansible.utils.ipaddr('netmask') }}"
dhcp_range_v4:
- "{{ provisioning_dhcp_v4_start }}"
- "{{ provisioning_dhcp_v4_end }}"
Expand All @@ -82,13 +82,13 @@ external_network:
- name: external
bridge: external
forward_mode: "{% if manage_external == 'y' %}nat{% else %}bridge{% endif %}"
address_v4: "{{ external_network_cidr_v4|nthhost(1)|default('', true) }}"
netmask_v4: "{{ external_network_cidr_v4|ipaddr('netmask') }}"
address_v4: "{{ external_network_cidr_v4|ansible.utils.nthhost(1)|default('', true) }}"
netmask_v4: "{{ external_network_cidr_v4|ansible.utils.ipaddr('netmask') }}"
dhcp_range_v4:
- "{{ external_dhcp_v4_start }}"
- "{{ external_dhcp_v4_end }}"
address_v6: "{{ external_network_cidr_v6|nthhost(1)|default('', true) }}"
prefix_v6: "{{ external_network_cidr_v6|ipaddr('prefix') }}"
address_v6: "{{ external_network_cidr_v6|ansible.utils.nthhost(1)|default('', true) }}"
prefix_v6: "{{ external_network_cidr_v6|ansible.utils.ipaddr('prefix') }}"
dhcp_range_v6:
- "{{ external_dhcp_v6_start }}"
- "{{ external_dhcp_v6_end }}"
Expand All @@ -103,7 +103,7 @@ external_network:
forwarders:
# Use 127.0.0.1 unless only IPv6 is enabled
- domain: "apps.{{ cluster_domain }}"
addr: "{% if external_network_cidr_v4|ipv4 != False %}127.0.0.1{% else %}::1{% endif %}"
addr: "{% if external_network_cidr_v4|ansible.utils.ipv4 != False %}127.0.0.1{% else %}::1{% endif %}"
srvs: "{{dns_externalsrvs | default([])}}"

# Provisioning network is bridged and external network is nated
Expand Down
12 changes: 6 additions & 6 deletions vm-setup/roles/common/tasks/extra_networks_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
block:
- set_fact:
extra_network_v4: "{{ [{
'address_v4': cidr|nthhost(1),
'netmask_v4': cidr|ipaddr('netmask'),
'dhcp_range_v4': [ cidr|nthhost(20), cidr|nthhost(60)],
'address_v4': cidr|ansible.utils.nthhost(1),
'netmask_v4': cidr|ansible.utils.ipaddr('netmask'),
'dhcp_range_v4': [ cidr|ansible.utils.nthhost(20), cidr|ansible.utils.nthhost(60)],
}]}}"
when: "{{ lookup('vars', network_name + '_cidr_v4') != '' }}"
vars:
Expand All @@ -34,9 +34,9 @@
block:
- set_fact:
extra_network_v6: "{{ [{
'address_v6': cidr|nthhost(1),
'prefix_v6': cidr|ipaddr('prefix'),
'dhcp_range_v6': [ cidr|nthhost(20), cidr|nthhost(60)],
'address_v6': cidr|ansible.utils.nthhost(1),
'prefix_v6': cidr|ansible.utils.ipaddr('prefix'),
'dhcp_range_v6': [ cidr|ansible.utils.nthhost(20), cidr|ansible.utils.nthhost(60)],
}]}}"
when: "{{ lookup('vars', network_name + '_cidr_v6') != '' }}"
vars:
Expand Down
2 changes: 1 addition & 1 deletion vm-setup/roles/virtbmc/tasks/setup_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

- name: set vbmc address from IPv4 networks if possible, otherwise IPv6
set_fact:
vbmc_address: "{% if vbmc_address_v4|ipv4 != False %}{{ vbmc_address_v4 }}{% else %}{{ vbmc_address_v6 }}{% endif %}"
vbmc_address: "{% if vbmc_address_v4|ansible.utils.ipv4 != False %}{{ vbmc_address_v4 }}{% else %}{{ vbmc_address_v6 }}{% endif %}"

# The connection uri is slightly different when using qemu:///system
# and requires the root user.
Expand Down

0 comments on commit 8b0d282

Please sign in to comment.