Lost in user permissions and playbooks

You have a typo. The key in the playbook is "sudo_user", not "sudo-user".

So, basically bad input, and it's just using defaults.

(In thinking of how to prevent this in the future, it's probably time to have play books whine about unknown keys, seeing if you want to add a comment YAML supports "#" just fine. Also the banner for a play should probably include more info, like what hosts it is running on, and what user and sudo user it is using. This is all pretty easy to do, so this is a useful reminder to do those things!)

--Michael

Thanks Michael,

My playbook is now working. I’m using:

  • name: deploy on Integration
    hosts: int
    sudo_user: webjava
    sudo: True
    gather_facts: False

vars_files:

  • tomcat/vars/locations.yml

tasks:

  • name: backup Tomcat configuration
    action: file path=${backup_home}/before_${jaw_version} state=directory owner=webjava group=webjava mode=0751

Two remarks:

  • sudo cannot be applied on a particular task, you have to apply it at the playbook level. If you have tasks that run at the user level, then tasks running with sudo, you need two plays in your playbook.
  • there is no documentation for the sudo_user key in a playbook (check http://ansible.github.com/playbooks.html#hosts-and-users),

Thanks,
Ludovic