blob: 9b0205f03d92290a54fc0e0a81d33b4a028a8106 [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"
Biser Milanovcd7fd562023-11-13 15:45:56 +0200112
113
114- hosts: lab-sp-a1
115 vars_files:
116 - vars.yaml
117 tasks:
118 - set_fact:
119 sp_iscsi0_mac: "{{ hostvars['undercloud-client']['port_node_1_iscsi0_mac'] }}"
120 sp_iscsi1_mac: "{{ hostvars['undercloud-client']['port_node_1_iscsi1_mac'] }}"
Biser Milanovb365ce82023-11-14 09:38:22 +0200121 ip_node_1_iscsi0: "{{ ip_node_1_iscsi0 }}/24"
122 ip_node_1_iscsi1: "{{ ip_node_1_iscsi1 }}/24"
Biser Milanovcd7fd562023-11-13 15:45:56 +0200123
124 - set_fact:
125 storpool_netplan: "{{ hostvars['localhost'].STORPOOL_ISCSI_NETPLAN.v }}"
126 no_log: true
127
128 - name: Provision the Netplan Template
129 no_log: true
130 become: true
131 ansible.builtin.copy:
132 content: "{{ storpool_netplan }}"
Biser Milanovede86e42023-11-14 14:23:30 +0200133 dest: /etc/netplan/60-storpool-iscsi.yaml
Biser Milanovcd7fd562023-11-13 15:45:56 +0200134
135 - name: Generate Netplan
136 become: true
137 ansible.builtin.command:
138 argv: ["netplan", "generate"]
139
140 - name: Restart Netplan
141 become: true
142 ansible.builtin.command:
143 argv: ["netplan", "apply"]
144
Biser Milanovcd7fd562023-11-13 15:45:56 +0200145- hosts: controller
146 vars_files:
147 - vars.yaml
148 tasks:
149 - set_fact:
150 iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi0_mac'] }}"
Biser Milanovb365ce82023-11-14 09:38:22 +0200151 iscsi_ip: "{{ ip_node_2_iscsi0 }}/24"
Biser Milanovcd7fd562023-11-13 15:45:56 +0200152
153 - set_fact:
154 systemd_networkd_iscsi: "{{ hostvars['localhost'].ISCSI_NODE_SYSTEMD_NETWORKD.v }}"
155 no_log: true
156
157 - name: Provision the Netplan Template for iSCSI Network 1
158 no_log: true
159 become: true
160 ansible.builtin.copy:
161 content: "{{ systemd_networkd_iscsi }}"
162 dest: /etc/systemd/network/60-storpool-iscsi-1.network
163
164 - set_fact:
165 iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi1_mac'] }}"
Biser Milanovb365ce82023-11-14 09:38:22 +0200166 iscsi_ip: "{{ ip_node_2_iscsi1 }}/24"
Biser Milanovcd7fd562023-11-13 15:45:56 +0200167
168 - set_fact:
169 systemd_networkd_iscsi: "{{ hostvars['localhost'].ISCSI_NODE_SYSTEMD_NETWORKD.v }}"
170 no_log: true
171
172 - name: Provision the Netplan Template for iSCSI Network 2
173 no_log: true
174 become: true
175 ansible.builtin.copy:
176 content: "{{ systemd_networkd_iscsi }}"
177 dest: /etc/systemd/network/61-storpool-iscsi-2.network
178
179 - name: Restart systemd-networkd to Apply the Network Configuration
180 become: true
181 ansible.builtin.command:
182 argv: [ "systemctl", "restart", "systemd-networkd" ]
183
184 - name: Set multipath.conf user_friendly_names to no
185 become: true
186 ansible.builtin.copy:
187 content: "defaults {\n user_friendly_names no\n getuid_callout \"/lib/udev/scsi_id --whitelisted --device=/dev/%n\"\n}\n"
188 dest: "/etc/multipath.conf"
189 owner: root
190 group: root
191 mode: '0644'
192
193 - name: Restart multipathd
194 become: true
195 ansible.builtin.command:
196 argv: [ "systemctl", "restart", "multipathd" ]