|
| 1 | +--- |
| 2 | +- name: Set MAC address facts |
| 3 | + ansible.builtin.set_fact: |
| 4 | + cifmw_nat64_appliance_ipv4_mac_address: "{{ '52:54:00' | community.general.random_mac }}" |
| 5 | + cifmw_nat64_appliance_ipv6_mac_address: "{{ '52:54:00' | community.general.random_mac }}" |
| 6 | + |
| 7 | +- name: Create the IPv4 libvirt network for nat64 |
| 8 | + community.libvirt.virt_net: |
| 9 | + command: define |
| 10 | + name: "{{ cifmw_nat64_network_ipv4_name }}" |
| 11 | + xml: "{{ lookup('template', 'ipv4_network.xml.j2') }}" |
| 12 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 13 | + |
| 14 | +- name: Ensure the IPv4 libvirt network for nat64 is created/started |
| 15 | + community.libvirt.virt_net: |
| 16 | + command: create |
| 17 | + name: "{{ cifmw_nat64_network_ipv4_name }}" |
| 18 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 19 | + |
| 20 | +- name: Ensure the IPv4 libvirt network for nat64 is active |
| 21 | + community.libvirt.virt_net: |
| 22 | + state: active |
| 23 | + name: "{{ cifmw_nat64_network_ipv4_name }}" |
| 24 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 25 | + |
| 26 | +- name: Ensure the IPv4 libvirt network for nat64 is enabled to autostart |
| 27 | + community.libvirt.virt_net: |
| 28 | + autostart: true |
| 29 | + name: "{{ cifmw_nat64_network_ipv4_name }}" |
| 30 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 31 | + |
| 32 | +- name: Create the IPv6 libvirt network for nat64 |
| 33 | + community.libvirt.virt_net: |
| 34 | + command: define |
| 35 | + name: "{{ cifmw_nat64_network_ipv6_name }}" |
| 36 | + xml: "{{ lookup('template', 'ipv6_network.xml.j2') }}" |
| 37 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 38 | + |
| 39 | +- name: Ensure the IPv6 libvirt network for nat64 is created/started |
| 40 | + community.libvirt.virt_net: |
| 41 | + command: create |
| 42 | + name: "{{ cifmw_nat64_network_ipv6_name }}" |
| 43 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 44 | + |
| 45 | +- name: Ensure the IPv6 libvirt network for nat64 network is active |
| 46 | + community.libvirt.virt_net: |
| 47 | + state: active |
| 48 | + name: "{{ cifmw_nat64_network_ipv6_name }}" |
| 49 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 50 | + |
| 51 | +- name: Ensure the IPv6 libvirt network for nat64 is enabled to autostart |
| 52 | + community.libvirt.virt_net: |
| 53 | + autostart: true |
| 54 | + name: "{{ cifmw_nat64_network_ipv6_name }}" |
| 55 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 56 | + |
| 57 | +- name: "Generate nat64-appliance UUID" |
| 58 | + ansible.builtin.set_fact: |
| 59 | + nat64_appliance_uuid: "{{ 99999999 | random | to_uuid | lower }}" |
| 60 | + |
| 61 | +- name: "Create the config-drive ISO for the nat64-appliance" |
| 62 | + vars: |
| 63 | + cifmw_config_drive_iso_image: "{{ cifmw_nat64_appliance_workdir }}/{{ nat64_appliance_uuid }}.iso" |
| 64 | + cifmw_config_drive_uuid: "{{ nat64_appliance_uuid }}" |
| 65 | + cifmw_config_drive_name: "{{ cifmw_nat64_appliance_name }}" |
| 66 | + cifmw_config_drive_hostname: "{{ cifmw_nat64_appliance_name }}" |
| 67 | + cifmw_config_drive_userdata: |
| 68 | + ssh_authorized_keys: |
| 69 | + - "{{ lookup('file', cifmw_nat64_appliance_ssh_pub_key) }}" |
| 70 | + write_files: |
| 71 | + - path: "/etc/nat64/config-data" |
| 72 | + owner: "root:root" |
| 73 | + content: "{{ lookup('template', 'config-data.j2') }}" |
| 74 | + cifmw_config_drive_networkconfig: |
| 75 | + network: |
| 76 | + version: 2 |
| 77 | + ethernets: |
| 78 | + id0: |
| 79 | + match: |
| 80 | + macaddress: "{{ cifmw_nat64_appliance_ipv4_mac_address }}" |
| 81 | + addresses: |
| 82 | + - "{{ cifmw_nat64_appliance_ipv4_address }}/{{ cifmw_nat64_network_ipv4_prefix }}" |
| 83 | + routes: |
| 84 | + - to: "0.0.0.0/0" |
| 85 | + via: "{{ cifmw_nat64_network_ipv4_address }}" |
| 86 | + on-link: true |
| 87 | + nameservers: |
| 88 | + addresses: |
| 89 | + - "{{ cifmw_nat64_network_ipv4_address }}" |
| 90 | + id1: |
| 91 | + match: |
| 92 | + macaddress: "{{ cifmw_nat64_appliance_ipv6_mac_address }}" |
| 93 | + addresses: |
| 94 | + - "{{ cifmw_nat64_appliance_ipv6_address }}/{{ cifmw_nat64_network_ipv6_prefix }}" |
| 95 | + ansible.builtin.include_role: |
| 96 | + name: config_drive |
| 97 | + |
| 98 | +- name: "Define nat64-appliance VM" |
| 99 | + community.libvirt.virt: |
| 100 | + command: define |
| 101 | + xml: "{{ lookup('template', 'domain.xml.j2') }}" |
| 102 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
| 103 | + |
| 104 | +- name: "Start VMs for type {{ vm_type }}" |
| 105 | + community.libvirt.virt: |
| 106 | + state: running |
| 107 | + name: "{{ cifmw_nat64_appliance_name }}" |
| 108 | + uri: "{{ cifmw_nat64_libvirt_uri }}" |
0 commit comments