Hi

My latest roadblock is trying to template sudoers. And I can't figure out 
why this won't work:

My playbook calling the role is simple enough:

---
- hosts: host1
  sudo: True
  gather_facts: no
  roles:
    - { role: myrole, sudoers: true, altsudoers: false }

And the tasks/main.yml goes like this:

---
- name: template the sudoers file
  template: src=sudoers.j2 dest=/etc/sudoers owner=root group=root 
mode=0400validate
="visudo -cf %s"
  when: sudoers

So nothing out of the ordinary. Even dull.
When it plays, this happens:

$ ansible-playbook playbook.yml  -s

PLAY [host1] **************************************************************

TASK: [myrole | template the sudoers file] 
**********************************
failed: [host1] => {"cmd": "visudo -cf 
/tmp/ansible-tmp-1399451238.53-220572162134665/source", "failed": true, 
"item": "", "rc": 2}
msg: [Errno 2] No such file or directory

When I go to the client machine to see the file, the whole dir 
"ansible-tmp-1399451238.53-220572162134665", is not there. It does not 
exist.

So one would think "permissions" or "sudo" issues, but this following task 
works with no issues whatsoever in the very same dir (/tmp):

- name: alternative copy the sudoers to /tmp
  copy: src=sudoers dest=/tmp/sudoers
  when: altsudoers

- name: alternative validate the /tmp copy
  shell: "/usr/sbin/visudo -c -f /tmp/sudoers && cp /tmp/sudoers 
/etc/sudoers"
  when: altsudoers

- name: alternative clean up
  shell: rm /tmp/sudoers removes=/tmp/sudoers
  when: altsudoers

It would seem this has nothing to do with permissions, then.
So what am I missing? in a very simple templating operation?

Thanks

-- 
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/4bbbdfdb-bfa2-4257-82c1-006f9e30a026%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to