It seems like you can't have multiple copy/template operations under one
name. I'm not sure if this is a YAML standard or an Ansible issue. I made
these files into templates and split the template operations out under two
names. Now it works. A little annoying but I did realize this was a
limitation when dealing with some apache configs. Here is the
tasks/main.yml file now:
---
- name: Install ddclient
apt: name={{ item }} state=latest
with_items:
- ddclient
- name: Copy ddclient configurations to server
template:
src=~/ansible/roles/pi_ddclient/templates/ddclient.conf.j2
dest=/etc/ddclient.conf owner=root group=root mode=0600 backup=yes
- name: Copy /etc/default/ddclient to server
template:
src=~/ansible/roles/pi_ddclient/templates/ddclient.j2
dest=/etc/default/ddclient owner=root group=root mode=0600 backup=yes
notify: restart ddclient
Works fine now. Thanks for the help!
On Sunday, January 4, 2015 10:52:11 AM UTC-5, Greg Andrews wrote:
>
> I believe the primary issue is that your pi_ddclient role's task file
> specifies the same path to the source file as your ad-hoc command. Your
> ad-hoc command doesn't know what roles are, so it needs the path to the
> source file to start with "roles/pi_ddclient/files/". However the role
> already knows the path to its files start that way.
>
> Telling the role to find the file
> "roles/pi_ddclient/files/etc/ddclient.conf" will make it look for the file
> "roles/pi_ddclient/files/roles/pi_ddclient/files/etc/ddclient.conf", which
> probably doesn't exist.
>
> In your pd_ddclient role's tasks/main.yml file, try these "copy:" lines:
>
> copy: src=etc/ddclient.conf dest=/etc/ddclient.conf owner=root
> group=root mode=0600 backup=yes
> copy: src=etc/default/ddclient dest=/etc/default/ddclient owner=root
> group=root mode=0600 backup=yes
>
>
>
> On Sat, Jan 3, 2015 at 7:55 AM, Chris Short <[email protected]
> <javascript:>> wrote:
>
>> This ad-hoc command works for me:
>>
>> ansible -s -m copy -a "src=roles/pi_ddclient/files/etc/ddclient.conf
>> dest=/etc/ddclient.conf owner=root group=root mode=0600 backup=yes" daffy
>>
>> However when I run the playbook containing the same command (with sudo:
>> true specified) it does not copy the file into place (no modification to
>> the file at all) but the play says it runs successfully!
>>
>> cshort-mba:ansible oaf357$ ansible-playbook pi_ddclient.yml -s
>> sudo password:
>>
>> PLAY [daffy]
>> ******************************************************************
>>
>> GATHERING FACTS
>> ***************************************************************
>> ok: [daffy]
>>
>> TASK: [common | apt-get update]
>> ***********************************************
>> ok: [daffy]
>>
>> TASK: [common | Installing commonly installed files]
>> **************************
>> ok: [daffy] => (item=curl,host,mercurial,ntpdate,vim)
>>
>> TASK: [common | Make Vim Default Editor]
>> **************************************
>> changed: [daffy]
>>
>> TASK: [pi_ddclient | Install ddclient]
>> ****************************************
>> ok: [daffy] => (item=ddclient)
>>
>> TASK: [pi_ddclient | Copy /etc/ddclient.conf and /etc/defaults/ddclient
>> to server] ***
>> ok: [daffy]
>>
>> PLAY RECAP
>> ********************************************************************
>> daffy : ok=6 changed=1 unreachable=0
>> failed=0
>>
>> Here's the pi_ddclient.yml file:
>>
>> ---
>> - hosts: daffy
>> roles:
>> - common
>> - pi_ddclient
>> sudo: true
>>
>> Here's the roles/pi_ddclient/tasks/main.yml file:
>>
>> ---
>> # Do all the ddclient things
>> - name: Install ddclient
>> apt: name={{ item }} state=latest
>> with_items:
>> - ddclient
>>
>> - name: Copy /etc/ddclient.conf and /etc/defaults/ddclient to server
>> copy: src=roles/pi_ddclient/files/etc/ddclient.conf
>> dest=/etc/ddclient.conf owner=root group=root mode=0600 backup=yes
>> copy: src=roles/pi_ddclient/files/etc/default/ddclient
>> dest=/etc/default/ddclient owner=root group=root mode=0600 backup=yes
>> notify: restart ddclient
>>
>> I should point out roles/pi_ddclient/files/etc/default/ddclient copies
>> over just fine.
>>
>> How can I debug successes in Ansible? Any thoughts on what is going wrong
>> here?
>>
>> Thank you in advance.
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/2d5bb1e9-8224-4afb-85f0-3536b863f980%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/2d5bb1e9-8224-4afb-85f0-3536b863f980%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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/36899787-0647-4b52-b0ae-746e67c297ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.