| - hosts: undercloud-client |
| vars_files: |
| - vars.yaml |
| tasks: |
| - name: Create Multipath iSCSI Networks |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "network", "create", "{{ item }}" ] |
| loop: |
| - "{{ network_1 }}" |
| - "{{ network_2 }}" |
| |
| - name: Create Multipath iSCSI Subnets |
| ansible.builtin.command: |
| argv: |
| - "{{ os_venv }}/bin/openstack" |
| - --os-cloud |
| - openstack-testing |
| - subnet |
| - create |
| - --subnet-range |
| - "{{ item.ip_range }}" |
| - --network |
| - "{{ item.network }}" |
| - "{{ item.subnet }}" |
| loop: |
| - { ip_range: "{{ network_ip_iscsi0 }}", network: "{{ network_1 }}", subnet: "{{ subnet_1 }}" } |
| - { ip_range: "{{ network_ip_iscsi1 }}", network: "{{ network_2 }}", subnet: "{{ subnet_2 }}" } |
| |
| # TODO: Support port security |
| - name: Create the Multipath iSCSI Ports |
| ansible.builtin.command: |
| argv: |
| - "{{ os_venv }}/bin/openstack" |
| - --os-cloud |
| - openstack-testing |
| - port |
| - create |
| - --network |
| - "{{ item.network }}" |
| - --fixed-ip |
| - "subnet={{ item.subnet }},ip-address={{ item.ip }}" |
| - --disable-port-security |
| - "{{ item.port }}" |
| loop: |
| - { network: "{{ network_1 }}", subnet: "{{ subnet_1 }}", ip: "{{ ip_node_1_iscsi0 }}", port: "{{ port_node_1_iscsi0 }}" } |
| - { network: "{{ network_2 }}", subnet: "{{ subnet_2 }}", ip: "{{ ip_node_1_iscsi1 }}", port: "{{ port_node_1_iscsi1 }}" } |
| - { network: "{{ network_1 }}", subnet: "{{ subnet_1 }}", ip: "{{ ip_node_2_iscsi0 }}", port: "{{ port_node_2_iscsi0 }}" } |
| - { network: "{{ network_2 }}", subnet: "{{ subnet_2 }}", ip: "{{ ip_node_2_iscsi1 }}", port: "{{ port_node_2_iscsi1 }}" } |
| |
| - name: Attach the Multipath iSCSI Ports to the StorPool Node |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "server", "add", "port", "{{ storpool_node }}", "{{ item }}" ] |
| loop: |
| - "{{ port_node_1_iscsi0 }}" |
| - "{{ port_node_1_iscsi1 }}" |
| |
| - name: Attach the Multipath iSCSI Ports to the OpenStack Node |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "server", "add", "port", "{{ openstack_node }}", "{{ item }}" ] |
| loop: |
| - "{{ port_node_2_iscsi0 }}" |
| - "{{ port_node_2_iscsi1 }}" |
| |
| - name: Get Information About port_node_1_iscsi0 |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_1_iscsi0 }}" ] |
| register: port_node_1_iscsi0_info |
| |
| - name: Get MAC Address of port_node_1_iscsi0 |
| ansible.builtin.set_fact: |
| port_node_1_iscsi0_mac: "{{ (port_node_1_iscsi0_info.stdout | from_json).mac_address }}" |
| |
| - name: Get Information About port_node_1_iscsi1 |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_1_iscsi1 }}" ] |
| register: port_node_1_iscsi1_info |
| |
| - name: Get MAC Address of port_node_1_iscsi1 |
| ansible.builtin.set_fact: |
| port_node_1_iscsi1_mac: "{{ (port_node_1_iscsi1_info.stdout | from_json).mac_address }}" |
| |
| - name: Get Information About port_node_2_iscsi0 |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_2_iscsi0 }}" ] |
| register: port_node_2_iscsi0_info |
| |
| - name: Get MAC Address of port_node_2_iscsi0 |
| ansible.builtin.set_fact: |
| port_node_2_iscsi0_mac: "{{ (port_node_2_iscsi0_info.stdout | from_json).mac_address }}" |
| |
| - name: Get Information About port_node_2_iscsi1 |
| ansible.builtin.command: |
| argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_2_iscsi1 }}" ] |
| register: port_node_2_iscsi1_info |
| |
| - name: Get MAC Address of port_node_2_iscsi1 |
| ansible.builtin.set_fact: |
| port_node_2_iscsi1_mac: "{{ (port_node_2_iscsi1_info.stdout | from_json).mac_address }}" |
| |
| - name: Dump Required Information for Next Stage |
| ansible.builtin.copy: |
| content: | |
| port_node_1_iscsi0_mac: {{ port_node_1_iscsi0_mac }} |
| port_node_1_iscsi1_mac: {{ port_node_1_iscsi1_mac }} |
| ip_node_1_iscsi0: {{ ip_node_1_iscsi0 }} |
| ip_node_1_iscsi1: {{ ip_node_1_iscsi1 }} |
| port_node_2_iscsi0_mac: {{ port_node_2_iscsi0_mac }} |
| port_node_2_iscsi1_mac: {{ port_node_2_iscsi1_mac }} |
| ip_node_2_iscsi0: {{ ip_node_2_iscsi0 }} |
| ip_node_2_iscsi1: {{ ip_node_2_iscsi1 }} |
| dest: "~/ansivars.yaml" |
| |
| |
| - hosts: lab-sp-a1 |
| vars_files: |
| - vars.yaml |
| tasks: |
| - set_fact: |
| sp_iscsi0_mac: "{{ hostvars['undercloud-client']['port_node_1_iscsi0_mac'] }}" |
| sp_iscsi1_mac: "{{ hostvars['undercloud-client']['port_node_1_iscsi1_mac'] }}" |
| ip_node_1_iscsi0: "{{ ip_node_1_iscsi0 }}/24" |
| ip_node_1_iscsi1: "{{ ip_node_1_iscsi1 }}/24" |
| |
| - set_fact: |
| storpool_netplan: "{{ hostvars['localhost'].STORPOOL_ISCSI_NETPLAN.v }}" |
| no_log: true |
| |
| - name: Provision the Netplan Template |
| no_log: true |
| become: true |
| ansible.builtin.copy: |
| content: "{{ storpool_netplan }}" |
| dest: /etc/netplan/60-storpool-iscsi.yaml |
| |
| - name: Generate Netplan |
| become: true |
| ansible.builtin.command: |
| argv: ["netplan", "generate"] |
| |
| - name: Restart Netplan |
| become: true |
| ansible.builtin.command: |
| argv: ["netplan", "apply"] |
| |
| - hosts: controller |
| vars_files: |
| - vars.yaml |
| tasks: |
| - set_fact: |
| iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi0_mac'] }}" |
| iscsi_ip: "{{ ip_node_2_iscsi0 }}/24" |
| |
| - set_fact: |
| systemd_networkd_iscsi: "{{ hostvars['localhost'].ISCSI_NODE_SYSTEMD_NETWORKD.v }}" |
| no_log: true |
| |
| - name: Provision the Netplan Template for iSCSI Network 1 |
| no_log: true |
| become: true |
| ansible.builtin.copy: |
| content: "{{ systemd_networkd_iscsi }}" |
| dest: /etc/systemd/network/60-storpool-iscsi-1.network |
| |
| - set_fact: |
| iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi1_mac'] }}" |
| iscsi_ip: "{{ ip_node_2_iscsi1 }}/24" |
| |
| - set_fact: |
| systemd_networkd_iscsi: "{{ hostvars['localhost'].ISCSI_NODE_SYSTEMD_NETWORKD.v }}" |
| no_log: true |
| |
| - name: Provision the Netplan Template for iSCSI Network 2 |
| no_log: true |
| become: true |
| ansible.builtin.copy: |
| content: "{{ systemd_networkd_iscsi }}" |
| dest: /etc/systemd/network/61-storpool-iscsi-2.network |
| |
| - name: Restart systemd-networkd to Apply the Network Configuration |
| become: true |
| ansible.builtin.command: |
| argv: [ "systemctl", "restart", "systemd-networkd" ] |
| |
| - name: Set multipath.conf user_friendly_names to no |
| become: true |
| ansible.builtin.copy: |
| content: "defaults {\n user_friendly_names no\n getuid_callout \"/lib/udev/scsi_id --whitelisted --device=/dev/%n\"\n}\n" |
| dest: "/etc/multipath.conf" |
| owner: root |
| group: root |
| mode: '0644' |
| |
| - name: Restart multipathd |
| become: true |
| ansible.builtin.command: |
| argv: [ "systemctl", "restart", "multipathd" ] |