On 28.01.2020 18:42, Michael Garris wrote:
- name: Output New VM IPaddress
debug:
msg: "New VM IPaddress: {{ vm_ipaddr.stdout }}"
- name: Set VM IP Address Fact
set_fact:
new_vm_ipaddr: "{{ vm_ipaddr.stdout }}"
- hosts: "{{ hostvars['localhost']['new_vm_ipaddr'] }}"
become: true
tasks:
- include_role:
name: "{{ item }}"
with_items:
- reg_n_packs
# - ansible_tower
Play run (ansible-playbook -K custom-vm.yml):
.........
TASK [Get IP Address of New VM]
************************************************************************************************************
changed: [localhost]
TASK [Output New VM IPaddress]
*************************************************************************************************************
ok: [localhost] => {
"msg": "New VM IPaddress: 192.168.122.206"
}
TASK [Set VM IP Address Fact]
**************************************************************************************************************
ok: [localhost]
[WARNING]: Could not match supplied host pattern, ignoring:
192.168.122.206
PLAY [192.168.122.206]
*********************************************************************************************************************
skipping: no hosts matched
In you subject you are hinting of problem with hostvars but that is
working fine.
As you can see it is trying to run against 192.168.122.206 but you get
"no hosts matched".
Your new host, 192.168.122.206, is not in your Ansible inventory so it
can't find it.
How is this new host supposed to appear/be added to the the inventory?
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ecc18b1e6ffc1ce53e178bf2962a37d1%40olstad.com.