sudo: a password is required ansible-playbook
14,290
Try to use --ask-become-pass
with your command line. You should then be prompted for the password.
Comments
-
Cassie almost 2 years
I have an ansible playbook which installs docker. It looks like this:
--- - hosts: local connection: local become: yes become_user: root tasks: - name: add docker's key apt_key: keyserver: hkp://p80.pool.sks-keyservers.net:80 id: 58118E89F3A912897C070ADBF76221572C52609D - name: add deb repo file: path=/etc/apt/sources.list.d/docker.list state=touch - name: register apt sources lineinfile: dest="/etc/apt/sources.list.d/docker.list" line="{{item}}" with_items: - "deb https://apt.dockerproject.org/repo ubuntu-trusty main" - name: install docker-engine apt: name=docker-engine state=present update-cache=yes force=yes
The problem is that when I run this playbook on my localhost I get an error:
fatal: [127.0.0.1]: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
So what parts of this playbook may cause such an error and how can I change them?
-
Oliver Charlesworth over 6 yearsThe
become
/become_user
is causing Ansible tosudo
up to theroot
user to perform each of these steps. -
Cassie over 6 years@OliverCharlesworth I thought it was more like a replacement for sudo:yes
-
-
Cassie over 6 yearsI have tried that. But I am not sure that it is a good solution for long-term
-
vmonteco over 6 years@Cassie Well the other solution implying a password would be to somehow store the password which wouldn't necessarly be better. Perhaps you'd be able to find some trick to store the password in a vault file but you'd need to enter an other password to unlock the vault file anyway. If you expected a different workflow than password use you should describe it in your question.
-
Cassie over 6 yearsOk, thanks for the help!
-
realtebo over 5 yearsI think long-term best practice is now store password in the vault. --ask-become-pass is now deprecated, too.