Move iSCSI config to the iSCSI playbooks

Change-Id: Id16bd2fa16933112c77b3084b3c925c60ba47f25
diff --git a/playbooks/setup-openstack-iscsi-multipath-storpool/pre.yaml b/playbooks/setup-openstack-iscsi-multipath-storpool/pre.yaml
index 42554d1..6fcc0f0 100644
--- a/playbooks/setup-openstack-iscsi-multipath-storpool/pre.yaml
+++ b/playbooks/setup-openstack-iscsi-multipath-storpool/pre.yaml
@@ -180,16 +180,12 @@
         port_node_1_sp_api_mac: "{{ hostvars['undercloud-client']['port_node_1_sp_api_mac'] }}"
         sp_sp0_mac: "{{ hostvars['undercloud-client']['port_sp0_mac'] }}"
         sp_sp1_mac: "{{ hostvars['undercloud-client']['port_sp1_mac'] }}"
-        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: "{{ hostvars['undercloud-client']['ip_node_1_iscsi0'] }}/24"
-        ip_node_1_iscsi1: "{{ hostvars['undercloud-client']['ip_node_1_iscsi1'] }}/24"
         ip_node_1_sp_api: "{{ ip_node_1_sp_api }}/24"
         ip_sp0: "{{ ip_sp0 }}/24"
         ip_sp1: "{{ ip_sp1 }}/24"
 
     - set_fact:
-        storpool_netplan: "{{ hostvars['localhost'].STORPOOL_NETPLAN.v }}"
+        storpool_netplan: "{{ hostvars['localhost'].STORPOOL_STORPOOL_NETPLAN.v }}"
       no_log: true
 
     - name: Provision the Netplan Template
@@ -197,7 +193,7 @@
       become: true
       ansible.builtin.copy:
         content: "{{ storpool_netplan }}"
-        dest: /etc/netplan/60-storpool.yaml
+        dest: /etc/netplan/61-storpool.yaml
 
     - set_fact:
         ip_node_1_sp_api: "{{ ip_sp_api_wo_net }}"
@@ -212,19 +208,6 @@
       ansible.builtin.command:
         argv: ["netplan", "apply"]
 
-    - name: Create Service to Apply Interface Configuration on Boot
-      no_log: true
-      become: true
-      ansible.builtin.copy:
-        content: "{{ hostvars['localhost'].STORPOOL_NETPLAN_SERVICE.v }}"
-        dest: /etc/systemd/system/netplan-fix.service
-
-    - name: Enable Service to Apply Interface Configuration on Boot
-      no_log: true
-      become: true
-      ansible.builtin.command:
-        argv: [ "systemctl", "enable", "netplan-fix" ]
-
     - name: Provision StorPool Deployment Configuration
       no_log: true
       ansible.builtin.lineinfile:
@@ -415,41 +398,7 @@
 
     - set_fact:
         port_node_2_sp_api_mac: "{{ hostvars['undercloud-client']['port_node_2_sp_api_mac'] }}"
-        mac_node_2_iscsi0: "{{ hostvars['undercloud-client']['port_node_2_iscsi0_mac'] }}"
-        mac_node_2_iscsi1: "{{ hostvars['undercloud-client']['port_node_2_iscsi1_mac'] }}"
         ip_node_2_sp_api: "{{ ip_node_2_sp_api }}/24"
-        ip_node_2_iscsi0: "{{ hostvars['undercloud-client']['ip_node_2_iscsi0'] }}/24"
-        ip_node_2_iscsi1: "{{ hostvars['undercloud-client']['ip_node_2_iscsi1'] }}/24"
-
-    - set_fact:
-        iscsi_mac: "{{ mac_node_2_iscsi0 }}"
-        iscsi_ip: "{{ ip_node_2_iscsi0 }}"
-
-    - 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_ip: "{{ ip_node_2_iscsi1 }}"
-        iscsi_mac: "{{ mac_node_2_iscsi1 }}"
-
-    - 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
 
     - set_fact:
         iscsi_ip: "{{ ip_node_2_sp_api }}"
@@ -493,17 +442,3 @@
         argv: [ "ping", "-c1", "192.168.50.101" ]
       register: r
       until: r.rc == 0
-
-    - 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" ]
diff --git a/playbooks/setup-openstack-iscsi-multipath/pre.yaml b/playbooks/setup-openstack-iscsi-multipath/pre.yaml
index cb1c099..a48486b 100644
--- a/playbooks/setup-openstack-iscsi-multipath/pre.yaml
+++ b/playbooks/setup-openstack-iscsi-multipath/pre.yaml
@@ -109,3 +109,108 @@
           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: "{{ hostvars['undercloud-client']['ip_node_1_iscsi0'] }}/24"
+        ip_node_1_iscsi1: "{{ hostvars['undercloud-client']['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.network
+
+    - name: Generate Netplan
+      become: true
+      ansible.builtin.command:
+        argv: ["netplan", "generate"]
+
+    - name: Restart Netplan
+      become: true
+      ansible.builtin.command:
+        argv: ["netplan", "apply"]
+
+    - name: Create Service to Apply Interface Configuration on Boot
+      no_log: true
+      become: true
+      ansible.builtin.copy:
+        content: "{{ hostvars['localhost'].STORPOOL_NETPLAN_SERVICE.v }}"
+        dest: /etc/systemd/system/netplan-fix.service
+
+    - name: Enable Service to Apply Interface Configuration on Boot
+      no_log: true
+      become: true
+      ansible.builtin.command:
+        argv: [ "systemctl", "enable", "netplan-fix" ]
+
+    - name: Provision StorPool Deployment Configuration
+      no_log: true
+      ansible.builtin.lineinfile:
+        path: /home/ubuntu/.ssh/authorized_keys
+        line: "{{ STORPOOL_DEPLOY_KEY_PUB['v'] }}"
+        insertafter: EOF
+
+- hosts: controller
+  vars_files:
+    - vars.yaml
+  tasks:
+    - set_fact:
+        iscsi_mac: "{{ hostvars['undercloud-client']['port_node_2_iscsi0_mac'] }}"
+        iscsi_ip: "{{ hostvars['undercloud-client']['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: "{{ hostvars['undercloud-client']['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" ]
\ No newline at end of file