diff --git a/ansible/seed-vm.yml b/ansible/seed-vm.yml index 6a5d8abc7..296c08bfc 100644 --- a/ansible/seed-vm.yml +++ b/ansible/seed-vm.yml @@ -75,3 +75,34 @@ libvirt_vm_interfaces: "{{ seed_hostvars.seed_vm_interfaces }}" libvirt_vm_image_cache_path: "{{ image_cache_path }}" become: True + + tasks: + - name: Check the seed VM's IP address + shell: virsh domifaddr {{ seed_vm_name }} | awk 'NR > 2 { print $4 }' + register: ifaddr_result + changed_when: False + become: True + until: "{{ ifaddr_result | failed or ifaddr_result.stdout != '' }}" + retries: 60 + delay: 1 + + # Generate an inventory file for the seed VM. Note that this host will not + # be accessible to this instance of Ansible - another process should be + # started. + - name: Ensure the inventory contains a group variables file for the seed + local_action: + module: copy + content: | + --- + # Do not edit this file - it is managed by Ansible and changes will be lost. + # Ansible inventory file for the Kayobe seed VM. + # This host will provide the Bifrost undercloud. + ansible_host: "{{ ifaddr_result.stdout_lines[0] | ipaddr('address') }}" + dest: "{{ kayobe_config_path }}/inventory/group_vars/seed/ansible-host" + + - name: Wait for SSH access to the seed VM + local_action: + module: wait_for + host: "{{ ifaddr_result.stdout_lines[0] | ipaddr('address') }}" + port: 22 + state: started