Search code examples
dockeransiblesudoansible-2.x

sudo: a password is required ansible-playbook


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?


Solution

  • Try to use --ask-become-pass with your command line. You should then be prompted for the password.