代码之家  ›  专栏  ›  技术社区  ›  Cassie

sudo:需要密码和剧本[副本]

  •  2
  • Cassie  · 技术社区  · 7 年前

    我有一个安装docker的ansible剧本。看起来是这样的:

    ---
    - 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
    

    问题是,当我在本地主机上运行此playbook时,出现了一个错误:

    fatal: [127.0.0.1]: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
    

    那么,这个剧本的哪些部分可能会导致这样的错误,我该如何更改它们?

    1 回复  |  直到 7 年前
        1
  •  14
  •   vmonteco    7 年前

    尝试使用 --ask-become-pass 使用命令行。然后会提示您输入密码。