Refactoring + final touches
This commit is contained in:
28
ansible/roles/p2p_network/tasks/main.yml
Normal file
28
ansible/roles/p2p_network/tasks/main.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: Validate p2p NICs exist on this node
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- priv_nic_1 in ansible_facts['interfaces']
|
||||
- priv_nic_2 in ansible_facts['interfaces']
|
||||
fail_msg: >-
|
||||
One or both p2p NICs not found on {{ inventory_hostname }}.
|
||||
Expected: {{ priv_nic_1 }}, {{ priv_nic_2 }}.
|
||||
Available interfaces: {{ ansible_facts['interfaces'] | join(', ') }}
|
||||
|
||||
- name: Configure p2p bridge in /etc/network/interfaces
|
||||
ansible.builtin.blockinfile:
|
||||
path: /etc/network/interfaces
|
||||
marker: "# {mark} ANSIBLE MANAGED BLOCK - p2p bridge"
|
||||
block: |
|
||||
auto p2p
|
||||
iface p2p inet static
|
||||
address {{ priv_ip }}/{{ ha_vip_cidr }}
|
||||
bridge-ports {{ priv_nic_1 }} {{ priv_nic_2 }}
|
||||
bridge-stp on
|
||||
bridge-fd 0
|
||||
register: p2p_network_p2p_bridge_config
|
||||
|
||||
- name: Apply network config # noqa: no-handler
|
||||
ansible.builtin.command: ifreload -a
|
||||
changed_when: true
|
||||
when: p2p_network_p2p_bridge_config is changed
|
||||
Reference in New Issue
Block a user