I have an Ansible controller and a remote host. On the remote host, we have 
created a guest VM instance. All of this is achieved through a playbook 
running on ansible controller. 

The guest VM does not have network connectivity to the ansible controller. 
The guest VM can only be accessed through the remote host. 

This is my hosts file on the ansible controller:

[root@mltr mltr_source_code]# cat hosts
[server]
10.204.74.245

[localserver]
127.0.0.1

[vms:vars]
ansible_connection=ssh
ansible_ssh_common_args='"-oStrictHostKeyChecking=no -oProxyCommand=\"ssh 
-A -W %h:%p [email protected]\"" ' -e ansible_ssh_user=root -e 
ansible_ssh_pass=contrail

The IP of the guest VM is dynamic in nature (it may differ each time you 
run the playbook as the playbook creates it), Therefore, I am using 
add_host module to add the IP address to the in-memory inventory. 

- name: Add the ucloud_vm created into in-memory of ansible hosts.
     vars:
       user_data: "{{ lookup('file', '/root/mltr_source_code/mini.ip') }}"
     add_host:
       name: '{{ user_data }}'
       groups: ucloud_vm_group
       debug:
         var: hostvars[ucloud_vm_group]
         verbosity: 4

Now, I would like to execute the next set of tasks/commands on the guest 
VM. How do I do it?

A sample example of a task to run commands on guest VM will be really 
helpful. 

Greetings,
Sandeep.

-- 
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/17a8ea86-782b-4ff6-8a3b-f52b871cdb19%40googlegroups.com.

Reply via email to