--- - hosts: servername remote_user: root tasks: - name: create ansible user for managing host user: name=ansible comment="Ansible User" - name: give ansible user sudo rights lineinfile: dest=/etc/sudoers state=present regexp='^ansible ALL\=' line='ansible ALL=(ALL) NOPASSWD:ALL'Than in ansible.cfg you set remote_user = ansible (so that you don't have to set remote_user in every playbook) and in playbooks use sudo: yes, like this:
validate='visudo -cf %s'
---
- hosts: servername
sudo: yes
- tasks:
- name: ...That gives you a passwordless user that can run commands as root without a password. The user module can take a password hash, and authorized keys can also be set up.
Adam
I would have to check whether this would create an account with an empty password hash (bad) or an invalid password hash (good).
Either way it is either dangerous or useless as is. My personal preference would be to create a user account for yourself (avoid a role account) give it a password, distribute an authorized key and require a password for sudo. This is marginally less convenient in that you need to provide a password but aids auditing and allows for multiple admins to run ansible as themselves.
Adam
--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/rpzQhE66ex0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9549dfee-9998-40f8-8cf1-7f14a80270cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The remote machine I am logging into currently only allows me to login via root, but I'd like to create another user and perform configurations as this user. I don't know how to do this, would someone point me to a few resources explaining this, or if someone is willing to explain via email, I would appreciate this too!