Hi Everyone,
I try to realise a playbook of autoprovisionning from scratch to "full installed application"
I use the "ansible inventory" for guide the provisionning
I use a lot of group who describe the configuration of the target:
if the entries (hostname) is in inventory ansible group "on-vmware" : the playbook use vsphere_guest module to create the host (by cloning) on a vmware cluster :
The cloning process is OK, my vm starts on a provisionning network => dhcp and vsphere_facts give to me IP adress of the new vm ( owing to vmtools).
my playbook :
**********************************************************************************************
- name : Configure/Check Host (Infra)
hosts: self-made - --> (self-made is a group where i put the new/existing ressource to create or check configuration)
connection: local
sudo: false
gather_facts: false
serial: 1
roles:
- role: infra/internal/vmware/Host --> this role create vmware guest by clonning and return {{ provisionning_temporary_ip }}
post_tasks:
- name: add_host in memory
local_action:
module: add_host
hostname: "{{ inventory_hostname }}"
ansible_ssh_host: "{{ provisionning_temporary_ip }}"
groups: hostsInProvisionningNetwork
- name: Configure/Check Network (OS / Infra)
hosts: hostsInProvisionningNetwork
gather_facts: ---> ( when true : Error SSH can't connect at "GATHERING FACTS" step )
( when false: SSH error on first tasks who try to connect ) lost information of ansible_ssh_host set
roles:
- role: os/network
**********************************************************************************************
I write some "roles" that work unitarily to customise guest os network / and relocate on the good vmware network.
this role use many informations about network are stored in variables on inventory network group_vars
I can't retrieve this information : i try a lot a test but with unsucess...
I try to "add_host" dynamicaly ( with ansible_ssh_host = {{ provisionning_temporary_ip }} ) but i lost the information about the static inventory (network group_vars) that I need for my next step role.
Have you a idea or a method ?
Thx a lot ..