blob: a48486b381ee211003d489f02cf315e193838339 [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'] }}"
121 ip_node_1_iscsi0: "{{ hostvars['undercloud-client']['ip_node_1_iscsi0'] }}/24"
122 ip_node_1_iscsi1: "{{ hostvars['undercloud-client']['ip_node_1_iscsi1'] }}/24"
123
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 }}"
133 dest: /etc/netplan/60-storpool-iscsi.network
134
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
145 - name: Create Service to Apply Interface Configuration on Boot
146 no_log: true
147 become: true
148 ansible.builtin.copy:
149 content: "{{ hostvars['localhost'].STORPOOL_NETPLAN_SERVICE.v }}"
150 dest: /etc/systemd/system/netplan-fix.service
151
152 - name: Enable Service to Apply Interface Configuration on Boot
153 no_log: true
154 become: true
155 ansible.builtin.command:
156 argv: [ "systemctl", "enable", "netplan-fix" ]
157
158 - name: Provision StorPool Deployment Configuration
159 no_log: true
160 ansible.builtin.lineinfile:
161 path: /home/ubuntu/.ssh/authorized_keys
162 line: "{{ STORPOOL_DEPLOY_KEY_PUB['v'] }}"
163 insertafter: EOF
164
165- hosts: controller
166 vars_files:
167 - vars.yaml
168 tasks:
169 - set_fact:
170 iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi0_mac'] }}"
171 iscsi_ip: "{{ hostvars['undercloud-client']['ip_node_2_iscsi0'] }}/24"
172
173 - set_fact:
174 systemd_networkd_iscsi: "{{ hostvars['localhost'].ISCSI_NODE_SYSTEMD_NETWORKD.v }}"
175 no_log: true
176
177 - name: Provision the Netplan Template for iSCSI Network 1
178 no_log: true
179 become: true
180 ansible.builtin.copy:
181 content: "{{ systemd_networkd_iscsi }}"
182 dest: /etc/systemd/network/60-storpool-iscsi-1.network
183
184 - set_fact:
185 iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi1_mac'] }}"
186 iscsi_ip: "{{ hostvars['undercloud-client']['ip_node_2_iscsi1'] }}/24"
187
188 - set_fact:
189 systemd_networkd_iscsi: "{{ hostvars['localhost'].ISCSI_NODE_SYSTEMD_NETWORKD.v }}"
190 no_log: true
191
192 - name: Provision the Netplan Template for iSCSI Network 2
193 no_log: true
194 become: true
195 ansible.builtin.copy:
196 content: "{{ systemd_networkd_iscsi }}"
197 dest: /etc/systemd/network/61-storpool-iscsi-2.network
198
199 - name: Restart systemd-networkd to Apply the Network Configuration
200 become: true
201 ansible.builtin.command:
202 argv: [ "systemctl", "restart", "systemd-networkd" ]
203
204 - name: Set multipath.conf user_friendly_names to no
205 become: true
206 ansible.builtin.copy:
207 content: "defaults {\n user_friendly_names no\n getuid_callout \"/lib/udev/scsi_id --whitelisted --device=/dev/%n\"\n}\n"
208 dest: "/etc/multipath.conf"
209 owner: root
210 group: root
211 mode: '0644'
212
213 - name: Restart multipathd
214 become: true
215 ansible.builtin.command:
216 argv: [ "systemctl", "restart", "multipathd" ]