Create cluster operator access information 41/117241/1
authorPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 29 Jan 2021 13:19:40 +0000 (14:19 +0100)
committerPawel Wieczorek <p.wieczorek2@samsung.com>
Fri, 29 Jan 2021 13:19:43 +0000 (14:19 +0100)
Issue-ID: INT-1601
Change-Id: I218ec5521d97eab298ea0556f690f2bc3d8ccbfa
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 6adcf5f..5b95421 100644 (file)
     - role: openstack/create_devstack_hosts
       hosts: "{{ cluster.hosts }}"
       operator_key: "{{ hostvars['operator0']['key']['public_key'] }}"
+- name: Create cluster operator access information
+  hosts: "operator0"
+  gather_facts: False
+  tasks:
+    - name: Add cluster hostnames to /etc/hosts file
+      lineinfile:
+        path: /etc/hosts
+        line: "{{ item.value + ' ' + item.key }}"
+      become: yes
+      loop: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"
index c3b40d2..c217aba 100644 (file)
@@ -27,3 +27,7 @@
     ansible_ssh_user: "{{ image.user }}"
     ansible_ssh_extra_args: "-o StrictHostKeyChecking=no"
     ansible_ssh_private_key_file: "~/.ssh/{{ keypair.key.name }}"
+
+- name: Add host to hosts dict
+  set_fact:
+    hosts_dict: "{{ hosts_dict|default({}) | combine( {new_host.server.name: new_host.server.private_v4} ) }}"