[ansible-project] Extract data from task in a variable

2018-05-04 Thread Uday Medhi
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/


After running it, I am getting the error below.

fatal: [10.200.2.6 -> 127.0.0.1]: FAILED! => {"changed": true, "cmd": 
"sshpass -p 'xyz@123456' scp /home/admin/schoolproject/deploy/
*Agent_[u'10.200.2.6'].zip* admin@*[u'10.200.2.6']*:/var/tmp/", "delta": 
"0:00:00.925109", "end": "2018-05-04 18:16:52.188862", "msg": "non-zero 
return code", "rc": 1, "start": "2018-05-04 18:16:51.263753", "stderr": 
"ssh: Could not resolve hostname u10.200.2.6: Name or service not 
known\r\nlost connection", "stderr_lines": ["ssh: Could not resolve 
hostname u10.200.2.6: Name or service not known", "lost connection"], 
"stdout": "", "stdout_lines": []}


How do I remove the quotes and square bracket *[u' ] *from the variable ?



-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4b44b6a5-b4be-4351-9805-d5bce92395a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Copy files with hostname to respective hosts

2018-05-03 Thread Uday Medhi
Hi,

I have three files,
host1.zip, host2.zip, host3.zip which are in the ansible server itself in a 
directory named "deploy".
And I have to copy the files the respective hosts.

host1.zip -to-> host1
host2.zip -to-> host2
host3.zip -to-> host3

I want ansible to look into the directory "deploy", check the files, match 
it with the hostnames and copy to the respective hosts.

How do I achieve the same ?

Regards,
Uday

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/40c8d064-1413-4b15-9414-ecd509650910%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Fetch the latest file only

2018-04-24 Thread Uday Medhi
no help ?

On Tuesday, April 24, 2018 at 5:37:35 PM UTC+5:30, Uday Medhi wrote:
>
> Hi,
>
> This is a simple ansible script to create a zip file with date and time.
>
> I want to fetch only the latest zip file to the destination server. How do 
> I fetch only the latest file ?
> - hosts: all
>   tasks:
>   - name: Ansible zip the configuration directory
> archive:
>   path: /home/admin/jboss/standalone/configuration
>   dest: /home/admin/jboss/standalone/configuration.{{ lookup('pipe', 
> 'date +%Y%m%d%H%M%S') }}.zip
>   format: zip
>
>
>
>
> Regards,
> Uday 
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6564fa98-7248-40ed-83c9-016d0bae282e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.