On 04.05.2018 15:06, Uday Medhi wrote:
Hi,
This is a role i wrote which will get the IP addresses of the Hosts and
then copy a file from the ansible server to the host server.

- name: Seeking the host IP address
  shell: |
ifconfig eth0 | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1
  register: ipv4_address
- debug: var=ipv4_address.stdout_lines

- name: Make the copy to CTM agents
  delegate_to: 127.0.0.1
  shell: sshpass -p 'xyz@123456' scp
/home/admin/schoolproject/deploy/Agent_{{ipv4_address.stdout_lines}}.zip
admin@{{ipv4_address.stdout_lines}}:/var/tmp/

You need to use ipv4_address.stdout not ipv4_address.stdout_lines.

By the way, if you gather facts, which is the default, you already have the ip in the variable {{ ansible_default_ipv4.address }}

--
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b315c3443e8de71cfc7c8280653189cb%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to