Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ansible filters from netcommon to utils #1492

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions vm-setup/roles/common/templates/ironic_nodes.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
"password": "{{ vbmc_password }}",
{% if vm_driver_tmp =='redfish' -%}
"port": "8000",
"address": "{{vm_driver_tmp}}+http://{{ lvars['host_ip'] | ipwrap }}:8000/redfish/v1/Systems/{{vm_id[node.name]}}",
"address": "{{vm_driver_tmp}}+http://{{ lvars['host_ip'] | ansible.utils.ipwrap }}:8000/redfish/v1/Systems/{{vm_id[node.name]}}",
{% elif vm_driver_tmp == 'redfish-virtualmedia' -%}
"port": "8000",
"address": "{{vm_driver_tmp}}+http://{{ lvars['host_ip'] | ipwrap }}:8000/redfish/v1/Systems/{{vm_id[node.name]}}",
"address": "{{vm_driver_tmp}}+http://{{ lvars['host_ip'] | ansible.utils.ipwrap }}:8000/redfish/v1/Systems/{{vm_id[node.name]}}",
{% elif vm_driver_tmp == 'redfish-uefihttp' -%}
"port": "8000",
"address": "{{vm_driver_tmp}}+http://{{ lvars['host_ip'] | ipwrap }}:8000/redfish/v1/Systems/{{vm_id[node.name]}}",
"address": "{{vm_driver_tmp}}+http://{{ lvars['host_ip'] | ansible.utils.ipwrap }}:8000/redfish/v1/Systems/{{vm_id[node.name]}}",
{% else -%}
"port": "{{ node.virtualbmc_port }}",
"address": "{{vm_driver_tmp}}://{{lvars['host_ip'] | ipwrap }}:{{node.virtualbmc_port}}",
"address": "{{vm_driver_tmp}}://{{lvars['host_ip'] | ansible.utils.ipwrap }}:{{node.virtualbmc_port}}",
{% endif -%}
"deploy_kernel": "http://{{ provisioning_url_host }}/images/ironic-python-agent.kernel",
"deploy_ramdisk": "http://{{ provisioning_url_host }}/images/ironic-python-agent.initramfs"
Expand Down
4 changes: 2 additions & 2 deletions vm-setup/roles/libvirt/templates/network.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% set ironic_name = ironic_prefix + flavor + "_" + num|string %}
{% set hostname_format = lookup('vars', flavor + '_hostname_format', default=flavor + '-%d') %}
{% set hostname = hostname_format % num %}
<host mac='{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v4[0]|ipmath(ns.index|int)}}'>
<host mac='{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v4[0]|ansible.utils.ipmath(ns.index|int)}}'>
<lease expiry='{{ item.lease_expiry }}'/>
</host>
{% set ns.index = ns.index + 1 %}
Expand Down Expand Up @@ -90,7 +90,7 @@
{% set ironic_name = ironic_prefix + flavor + "_" + num|string %}
{% set hostname_format = lookup('vars', flavor + '_hostname_format', default=flavor + '-%d') %}
{% set hostname = hostname_format % num %}
<host id='00:03:00:01:{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v6[0]|ipmath(ns.index|int)}}'>
<host id='00:03:00:01:{{ node_mac_map.get(ironic_name).get(item.name)}}' name='{{hostname}}' ip='{{item.dhcp_range_v6[0]|ansible.utils.ipmath(ns.index|int)}}'>
<lease expiry='{{ item.lease_expiry }}'/>
</host>
{% set ns.index = ns.index + 1 %}
Expand Down
6 changes: 3 additions & 3 deletions vm-setup/roles/virtbmc/tasks/setup_tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@

- 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.
- name: set qemu uri for qemu:///system usage
set_fact:
vbmc_libvirt_uri: "qemu+ssh://root@{{ vbmc_address | ipwrap }}/system?&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
vbmc_libvirt_uri: "qemu+ssh://root@{{ vbmc_address | ansible.utils.ipwrap }}/system?&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
when: libvirt_uri == "qemu:///system"

- name: set qemu uri for qemu:///session usage
set_fact:
vbmc_libvirt_uri: "qemu+ssh://{{ non_root_user }}@{{ vbmc_address | ipwrap }}/session?socket=/run/user/{{ non_root_user_uid }}/libvirt/libvirt-sock&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
vbmc_libvirt_uri: "qemu+ssh://{{ non_root_user }}@{{ vbmc_address | ansible.utils.ipwrap }}/session?socket=/run/user/{{ non_root_user_uid }}/libvirt/libvirt-sock&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
when: vbmc_libvirt_uri is not defined

- name: Create VirtualBMC directories
Expand Down