Add Ansible group variables file for seed Ansible SSH host
We currently use a libvirt network with dynamic IP address allocation for the seed VM. After creation of the seed, determine it's IP address and update the inventory to allow access to it.
This commit is contained in:
parent
efc7424e26
commit
614958486d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user