Skip to content

Commit

Permalink
Merge pull request #362 from bshephar/network-config-template
Browse files Browse the repository at this point in the history
Rework network_config_template to accept j2
  • Loading branch information
openshift-merge-robot authored Sep 23, 2023
2 parents 19682ee + de821be commit 0a8fd83
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion roles/edpm_network_config/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ edpm_network_config_manage_service: true
edpm_network_config_nmstate: false
edpm_network_config_os_net_config_mappings: {}
edpm_network_config_safe_defaults: true
edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2
edpm_network_config_template: ""
edpm_network_config_override: ""
edpm_bond_interface_ovs_options: "bond_mode=active-backup"
4 changes: 2 additions & 2 deletions roles/edpm_network_config/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ argument_specs:
case of failing while applying the provided net config.
default: true
edpm_network_config_template:
type: path
type: str
description: "Which settings template should be rendered."
default: templates/single_nic_vlans/single_nic_vlans.j2
default: ""
edpm_network_config_override:
type: str
description: "Optional template content overrides"
Expand Down
34 changes: 33 additions & 1 deletion roles/edpm_network_config/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,39 @@
- name: Converge
hosts: all
vars:
edpm_network_config_template: templates/standalone.j2
edpm_network_config_template: |
---
{% set control_virtual_ip = net_vip_map.ctlplane %}
{% set public_virtual_ip = vip_port_map.external.ip_address %}
{% if ':' in control_virtual_ip %}
{% set control_virtual_cidr = 128 %}
{% else %}
{% set control_virtual_cidr = 32 %}
{% endif %}
{% if ':' in public_virtual_ip %}
{% set public_virtual_cidr = 128 %}
{% else %}
{% set public_virtual_cidr = 32 %}
{% endif %}
network_config:
- type: ovs_bridge
name: br-ctlplane
use_dhcp: false
mtu: {{ ctlplane_mtu }}
ovs_extra:
- br-set-external-id br-ctlplane bridge-id br-ctlplane
addresses:
- ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }}
- ip_netmask: {{ control_virtual_ip}}/{{ control_virtual_cidr }}
- ip_netmask: {{ public_virtual_ip}}/{{ public_virtual_cidr }}
routes: {{ ctlplane_host_routes }}
dns_servers: {{ ctlplane_dns_nameservers }}
domain: {{ dns_search_domains }}
members:
- type: interface
name: {{ neutron_public_interface_name }}
primary: true
mtu: {{ ctlplane_mtu }}
edpm_network_config_override: |
---
{% set control_virtual_ip = net_vip_map.ctlplane %}
Expand Down
8 changes: 4 additions & 4 deletions roles/edpm_network_config/tasks/os_net_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
mode: '0644'
backup: true
when:
- edpm_network_config_override != ""
- edpm_network_config_template == ""
- name: Render network_config from template
no_log: "{{ edpm_network_config_hide_sensitive_logs | bool }}"
ansible.builtin.template:
src: "{{ edpm_network_config_template }}"
ansible.builtin.copy:
content: "{{ edpm_network_config_template }}"
dest: "{{ nic_config_file }}"
mode: '0644'
backup: true
when:
- edpm_network_config_override == ""
- edpm_network_config_template != ""
- name: Run edpm_os_net_config_module with network_config
edpm_os_net_config:
config_file: "{{ nic_config_file }}"
Expand Down

0 comments on commit 0a8fd83

Please sign in to comment.