Problem with templates

126 views
Skip to first unread message

Roger Gomez

unread,
Apr 7, 2016, 6:39:43 PM4/7/16
to Ansible Project
I have this very simple playbook
---
- hosts:
    - all
  gather_facts: no
  vars:
    - my_list: [1,2,3,4]
  tasks:
    - name: TEMPLATE
      template:
       dest='/home/Ansible/dest.y'
       src='src.j2'

And when I run the playbook I got:
failed: [HOST-A] => {"failed": true}
msg: missing required arguments: dest


Any idea?
Thanks.

J Hawkesworth

unread,
Apr 8, 2016, 6:02:10 AM4/8/16
to Ansible Project
Hi

Not sure exactly but it looks like you're mixing key=value args and yaml styl args.  Try the following

---
- hosts: all
  gather_facts: no
  vars:
    - my_list: [1,2,3,4]
  tasks:
    - name: TEMPLATE
      template:
        dest: /home/Ansible/dest.y
        src: src.j2

Or

---
- hosts: all
  gather_facts: no
  vars:
    - my_list: [1,2,3,4]
  tasks:
    - name: TEMPLATE
      template: dest=/home/Ansible/dest.y src=src.j2

Roger Gomez

unread,
Apr 8, 2016, 10:49:53 AM4/8/16
to Ansible Project
Hi  J Hawkesworth, thanks for taking the time to answer my question. I did try before both of your suggestions and the same error, I have multiple Ansible machine and only in this one does not work. Is basically ignoring the dest argument, definitely the output of the error is not correct. My inventory is pretty simple, I actually found this issue trying to do something else so I create this small test to narrow down the problem.
Thanks.

Roger Gomez

unread,
Apr 8, 2016, 10:56:54 AM4/8/16
to Ansible Project
This is the output of the whole test:
➜  Ansible cat test.yml
---
- hosts: localhost
  gather_facts: no
  vars:
    - my_list: [1,2,3,4]
  tasks:
    - name: TEMPLATE
      template: dest=/home/Ansible/dest.y src=src.j2
➜  Ansible ansible-playbook test.yml

PLAY [localhost] **************************************************************

TASK: [TEMPLATE] **************************************************************
failed: [localhost] => {"failed": true}
msg: missing required arguments: dest

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/home/test.retry

localhost                  : ok=0    changed=0    unreachable=0    failed=1


Thanks.

Vamberto Junior

unread,
Apr 8, 2016, 2:33:32 PM4/8/16
to Ansible Project
Hellow Roger

I put this way and works for me


- name: Copy ntp.conf from template

 template: src=ntp.conf.j2 dest=/etc/ntp.conf
 when: ansible_hostname != 'vmlog'
 notify:
  - restart ntp


Try to put without ' '  

Roger Gomez

unread,
Apr 11, 2016, 9:58:20 AM4/11/16
to Ansible Project
Hi Vamberto, thank you so much for responding.
Take a look to my previous post, I did not use any quotation and still did not work. I know also that if I copy the same playbook to another Ansible Machine it does work perfectly, I was trying to find here if there is any know issue that shows an output like this, definitely I think that there is some kind of problem with output because the destination is provided. Any idea of what could lead to this behavior?
Reply all
Reply to author
Forward
0 new messages