Inject operator key when launching cluster instances 40/117240/1
authorPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 29 Jan 2021 10:30:18 +0000 (11:30 +0100)
committerPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 29 Jan 2021 10:30:22 +0000 (11:30 +0100)
Issue-ID: INT-1601
Change-Id: Ie2c606d7afa191386124a0ad49619de40fb15c06
Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
deployment/noheat/infra-openstack/ansible/create.yml
deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/create_host.yml

index 74d6d1f..6adcf5f 100644 (file)
@@ -1,5 +1,5 @@
 ---
-- name: Create infrastructure
+- name: Prepare infrastructure and create operation instances
   hosts: localhost
   connection: local
   gather_facts: False
@@ -9,8 +9,7 @@
     - openstack/create_devstack_keypair
     - role: openstack/create_devstack_hosts
       hosts: "{{ operation.hosts }}"
-    - role: openstack/create_devstack_hosts
-      hosts: "{{ cluster.hosts }}"
+      operator_key: "dummy"
 - name: Create cluster operator access keypair
   hosts: "operator0"
   gather_facts: False
       community.crypto.openssh_keypair:
         path: "~/.ssh/{{ keypair.name }}"
       register: key
-- name: Deploy cluster operator public key
-  hosts: "cluster0"
+- name: Create cluster instances
+  hosts: localhost
+  connection: local
   gather_facts: False
-  tasks:
-    - name: Wait for system to become reachable
-      wait_for_connection:
-    - name: Add authorized key
-      ansible.posix.authorized_key:
-        user: "{{ image.user }}"
-        state: present
-        key: "{{ hostvars['operator0']['key']['public_key'] }}"
+  roles:
+    - role: openstack/create_devstack_hosts
+      hosts: "{{ cluster.hosts }}"
+      operator_key: "{{ hostvars['operator0']['key']['public_key'] }}"
index 7fed578..c3b40d2 100644 (file)
     boot_from_volume: true
     terminate_volume: true
     volume_size: "{{ host.volume_size | default(10) }}"
+    userdata: |
+      #cloud-config
+      ssh_authorized_keys:
+        - "{{ operator_key }}"
   register: new_host
 
 - name: Add host to inventory