36 lines
1.2 KiB
YAML
Executable file
36 lines
1.2 KiB
YAML
Executable file
---
|
|
- name: Set gray interface (10.100.x.x)
|
|
ansible.builtin.set_fact:
|
|
interface_1: "{{ item.key }}"
|
|
interface_ip_1_with_mask: "{{ item.value.ipv4.address }}/{{ item.value.ipv4.prefix }}"
|
|
loop: "{{ ansible_facts | dict2items }}"
|
|
when:
|
|
- item.value.ipv4 is defined
|
|
- item.value.ipv4.address is defined
|
|
- item.value.ipv4.address.startswith('10.100')
|
|
|
|
- name: Set white interface
|
|
ansible.builtin.set_fact:
|
|
interface_2: "{{ item.key }}"
|
|
interface_ip_2_with_mask: "{{ item.value.ipv4.address }}/{{ item.value.ipv4.prefix }}"
|
|
loop: "{{ ansible_facts | dict2items }}"
|
|
when:
|
|
- item.value.ipv4 is defined
|
|
- item.value.ipv4.address is defined
|
|
- not item.value.ipv4.address.startswith('10.100')
|
|
- not item.value.ipv4.address.startswith('127.')
|
|
|
|
- name: Create backup
|
|
ansible.builtin.command: cp /etc/netplan/99-netcfg-vmware.yaml /etc/netplan/99-netcfg-vmware.yaml.bak
|
|
|
|
- name: Copy new netplan config
|
|
ansible.builtin.template:
|
|
src: templates/99-netcfg-vmware.yaml.j2
|
|
dest: /etc/netplan/99-netcfg-vmware.yaml
|
|
owner: root
|
|
group: root
|
|
mode: '0600'
|
|
|
|
- name: Apply new netplan
|
|
ansible.builtin.command: sudo netplan apply
|
|
...
|