---
# Any step that should happen after the deployment of the overcloud playbook
# This could be validation of installation, etc
- name: Fetch key for SSH to the overcloud
  hosts: undercloud
  gather_facts: no
  become: yes
  become_user: "{{ installer.user.name }}"
  tasks:
      - name: fetch the private key file from the undercloud
        fetch:
            src: "~/.ssh/id_rsa"
            dest: "{{ inventory_dir }}/id_rsa_overcloud"
            flat: yes

- name: Update the inventory file
  hosts: localhost
  gather_facts: no
  tasks:
      - name: update file permissions
        file:
            path: "{{ inventory_dir }}/id_rsa_overcloud"
            mode: 0600

      - name: update our ansible ssh configuration file
        template:
            src: "templates/ssh.config.ansible.j2"
            dest: "{{ inventory_dir }}/ansible.ssh.config"
            mode: 0755

---
# Any step that should happen after the deployment of the overcloud playbook
# This could be validation of installation, etc
- name: Fetch key for SSH to the overcloud
  hosts: undercloud
  gather_facts: no
  become: yes
  become_user: "{{ installer.user.name }}"
  tasks:
      - name: fetch the private key file from the undercloud
        fetch:
            src: "~/.ssh/id_rsa"
            dest: "{{ inventory_dir }}/id_rsa_overcloud"
            flat: yes

- name: Update the inventory file
  hosts: localhost
  gather_facts: no
  tasks:
      - name: update file permissions
        file:
            path: "{{ inventory_dir }}/id_rsa_overcloud"
            mode: 0600

      - name: update our ansible ssh configuration file
        template:
            src: "templates/ssh.config.ansible.j2"
            dest: "{{ inventory_dir }}/ansible.ssh.config"
            mode: 0755

      - name: Update Inventory
        add_host:
          name: "{{ item }}"
          ansible_ssh_user: "heat-admin"
        with_items: groups['openstack_nodes'] | difference(["undercloud"])
        # todo(yfried): Do we need to flush the inventory somehow?

      - name: Generate new Inventory file
        template:
          dest: "{{ lookup('env', 'PWD') }}/hosts-{{ lookup('env', 'USER') }}"
          src: ../../provisioner/templates/inventory.j2

      - name: Link to new Inventory file
        file:
          dest: "{{ lookup('env', 'PWD') }}/hosts"
          state: link
          src: "{{ lookup('env', 'PWD') }}/hosts-{{ lookup('env', 'USER') }}"

Update inventory with overcloud user
[ospd] Update inventory with overcloud user

OSPd deploys overcloud with "heat-admin" user.
Updates overcloud nodes with that user in inventory and file.
