blob: cb1c0997b608c02cc457cf4f8bdb91afc18f66fa [file] [log] [blame]
Biser Milanovdd597bc2023-05-12 17:42:11 +03001- hosts: undercloud-client
2 vars_files:
3 - vars.yaml
4 tasks:
5 - name: Create Multipath iSCSI Networks
6 ansible.builtin.command:
7 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "network", "create", "{{ item }}" ]
8 loop:
9 - "{{ network_1 }}"
10 - "{{ network_2 }}"
11
12 - name: Create Multipath iSCSI Subnets
13 ansible.builtin.command:
14 argv:
15 - "{{ os_venv }}/bin/openstack"
16 - --os-cloud
17 - openstack-testing
18 - subnet
19 - create
20 - --subnet-range
21 - "{{ item.ip_range }}"
22 - --network
23 - "{{ item.network }}"
24 - "{{ item.subnet }}"
25 loop:
26 - { ip_range: "{{ network_ip_iscsi0 }}", network: "{{ network_1 }}", subnet: "{{ subnet_1 }}" }
27 - { ip_range: "{{ network_ip_iscsi1 }}", network: "{{ network_2 }}", subnet: "{{ subnet_2 }}" }
28
29 # TODO: Support port security
30 - name: Create the Multipath iSCSI Ports
31 ansible.builtin.command:
32 argv:
33 - "{{ os_venv }}/bin/openstack"
34 - --os-cloud
35 - openstack-testing
36 - port
37 - create
38 - --network
39 - "{{ item.network }}"
40 - --fixed-ip
41 - "subnet={{ item.subnet }},ip-address={{ item.ip }}"
42 - --disable-port-security
43 - "{{ item.port }}"
44 loop:
45 - { network: "{{ network_1 }}", subnet: "{{ subnet_1 }}", ip: "{{ ip_node_1_iscsi0 }}", port: "{{ port_node_1_iscsi0 }}" }
46 - { network: "{{ network_2 }}", subnet: "{{ subnet_2 }}", ip: "{{ ip_node_1_iscsi1 }}", port: "{{ port_node_1_iscsi1 }}" }
47 - { network: "{{ network_1 }}", subnet: "{{ subnet_1 }}", ip: "{{ ip_node_2_iscsi0 }}", port: "{{ port_node_2_iscsi0 }}" }
48 - { network: "{{ network_2 }}", subnet: "{{ subnet_2 }}", ip: "{{ ip_node_2_iscsi1 }}", port: "{{ port_node_2_iscsi1 }}" }
49
50 - name: Attach the Multipath iSCSI Ports to the StorPool Node
51 ansible.builtin.command:
52 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "server", "add", "port", "{{ storpool_node }}", "{{ item }}" ]
53 loop:
54 - "{{ port_node_1_iscsi0 }}"
55 - "{{ port_node_1_iscsi1 }}"
56
57 - name: Attach the Multipath iSCSI Ports to the OpenStack Node
58 ansible.builtin.command:
59 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "server", "add", "port", "{{ openstack_node }}", "{{ item }}" ]
60 loop:
61 - "{{ port_node_2_iscsi0 }}"
62 - "{{ port_node_2_iscsi1 }}"
63
64 - name: Get Information About port_node_1_iscsi0
65 ansible.builtin.command:
66 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_1_iscsi0 }}" ]
67 register: port_node_1_iscsi0_info
68
69 - name: Get MAC Address of port_node_1_iscsi0
70 ansible.builtin.set_fact:
71 port_node_1_iscsi0_mac: "{{ (port_node_1_iscsi0_info.stdout | from_json).mac_address }}"
72
73 - name: Get Information About port_node_1_iscsi1
74 ansible.builtin.command:
75 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_1_iscsi1 }}" ]
76 register: port_node_1_iscsi1_info
77
78 - name: Get MAC Address of port_node_1_iscsi1
79 ansible.builtin.set_fact:
80 port_node_1_iscsi1_mac: "{{ (port_node_1_iscsi1_info.stdout | from_json).mac_address }}"
81
82 - name: Get Information About port_node_2_iscsi0
83 ansible.builtin.command:
84 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_2_iscsi0 }}" ]
85 register: port_node_2_iscsi0_info
86
87 - name: Get MAC Address of port_node_2_iscsi0
88 ansible.builtin.set_fact:
89 port_node_2_iscsi0_mac: "{{ (port_node_2_iscsi0_info.stdout | from_json).mac_address }}"
90
91 - name: Get Information About port_node_2_iscsi1
92 ansible.builtin.command:
93 argv: [ "{{ os_venv }}/bin/openstack", "--os-cloud", "openstack-testing", "port", "show", "--format", "json", "{{ port_node_2_iscsi1 }}" ]
94 register: port_node_2_iscsi1_info
95
96 - name: Get MAC Address of port_node_2_iscsi1
97 ansible.builtin.set_fact:
98 port_node_2_iscsi1_mac: "{{ (port_node_2_iscsi1_info.stdout | from_json).mac_address }}"
99
100 - name: Dump Required Information for Next Stage
101 ansible.builtin.copy:
102 content: |
103 port_node_1_iscsi0_mac: {{ port_node_1_iscsi0_mac }}
104 port_node_1_iscsi1_mac: {{ port_node_1_iscsi1_mac }}
105 ip_node_1_iscsi0: {{ ip_node_1_iscsi0 }}
106 ip_node_1_iscsi1: {{ ip_node_1_iscsi1 }}
107 port_node_2_iscsi0_mac: {{ port_node_2_iscsi0_mac }}
108 port_node_2_iscsi1_mac: {{ port_node_2_iscsi1_mac }}
109 ip_node_2_iscsi0: {{ ip_node_2_iscsi0 }}
110 ip_node_2_iscsi1: {{ ip_node_2_iscsi1 }}
111 dest: "~/ansivars.yaml"