Hi all,

My understanding of delegate_to is that it runs the task on the designated 
host, once for each host in the current group, and with the current host's 
variables.

I have this:

- hosts: 127.0.0.1
  connection: local
  - tasks:
    [ ... stuff ... ]
    - name: Copy override file for database information
      template: >
        src=templates/user_data.json
        dest={{ app_exec_dir }}/core/AWS_OVERRIDE.json
      delegate_to: "{{ retrieved_instance.public_ip }}"

I see this, where <proper host> is the correct IP address:

TASK: [Copy override file for database information] ***************************
<proper host> EXEC ['/bin/sh', '-c', 'mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281 && chmod a+rx 
$HOME/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281 && echo 
$HOME/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281']
<proper host> EXEC ['/bin/sh', '-c', u'rc=0; [ -r 
"/srv/sp/web/core/AWS_OVERRIDE.json" ] || rc=2; [ -f 
"/srv/sp/web/core/AWS_OVERRIDE.json" ] || rc=1; [ -d 
"/srv/sp/web/core/AWS_OVERRIDE.json" ] && echo 3 && exit 0; (/usr/bin/md5sum 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/sbin/md5sum -q 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/usr/bin/digest -a md5 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/sbin/md5 -q 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/usr/bin/md5 -n 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/bin/md5 -q 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/usr/bin/csum -h MD5 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (/bin/csum -h MD5 
/srv/sp/web/core/AWS_OVERRIDE.json 2>/dev/null) || (echo "${rc} 
/srv/sp/web/core/AWS_OVERRIDE.json")']
<proper host> PUT /var/folders/m4/mk3x6q_50dj_50jpx0763lm80000gn/T/tmpl9p7QM TO 
/Users/anderson/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281/source
<proper host> PUT /var/folders/m4/mk3x6q_50dj_50jpx0763lm80000gn/T/tmpB7_vdY TO 
/Users/anderson/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281/copy
<proper host> EXEC ['/bin/sh', '-c', '/usr/bin/python 
/Users/anderson/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281/copy; rm 
-rf /Users/anderson/.ansible/tmp/ansible-tmp-1399297955.21-265740010111281/ 
>/dev/null 2>&1']
failed: [127.0.0.1] => {"failed": true}
msg: Destination /srv/sp/web/core not writable

The directory does exist on the delegate_to host:

(sp_devops)GoatRodeo:devops anderson$ ssh -i keys/hoopdy.id_rsa ubuntu@<proper 
host>
ubuntu@ip-10-2-1-174:~$ ls /srv/sp/web/core
[... stuff ...]

If I add the directory to the *local* machine running Ansible, the script finds 
it. This is telling me that the template command is actually trying to copy to 
the local machine and not the delegate_to machine.

If this is not what delegate_to is for, is there another way to run a single 
task on a single host not in the current group without having to pop all the 
way back up to the playbook context and add another host: section?

Thanks,
-scott

-- 
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/76A6A584-E94E-48E5-BBB4-C41032F60E0B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to