使用docker角色时出错

时间:2018-04-24 23:58:44

标签: docker ansible

我在ubultu 16.04上使用ansible 我有安装docker的角色, 这是角色:

    - name: Install Docker and role dependencies
  apt:
    name: "{{ item }}"
    state: "present"
    install_recommends: False
  with_items:
    - "apt-transport-https"
    - "ca-certificates"
    - "software-properties-common"
    - "cron"

- name: Get upstream APT GPG key
  apt_key:
    id: "{{ docker_apt_key }}"
    keyserver: "{{ ansible_local.core.keyserver
                   if (ansible_local|d() and ansible_local.core|d() and
                       ansible_local.core.keyserver)
                   else 'hkp://pool.sks-keyservers.net' }}"
    state: "present"

- name: Configure upstream APT repository
  apt_repository:
    repo: "{{ docker_repository }}"
    state: "present"
    update_cache: True

- name: Install Docker
  apt:
    name: "docker-{{ docker_edition }}={{ docker_apt_package_name }}"
    state: "present"
    update_cache: True
    install_recommends: False
    cache_valid_time: "{{ docker_apt_cache_time }}"

当我执行剧本时, 我在步骤“获取上游APT GPG密钥”

时出现此错误
TASK [nickjj.docker : Install Docker and role dependencies] ************************************************************************************************************************************************
ok: [127.0.0.1] => (item=[u'apt-transport-https', u'ca-certificates', u'software-properties-common', u'cron'])

TASK [nickjj.docker : Get upstream APT GPG key] ************************************************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "Failed to find required executable gpg in paths: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"}
    to retry, use: --limit @/home/skaouech/work/ansible/plays.retry

请告知任何建议 THKS。

1 个答案:

答案 0 :(得分:1)

根据您发布的错误,您的目标主机看起来没有gpg二进制文件:

  

无法找到所需的可执行gpg ...

您可能需要安装gnupg,这可以通过ansible apt模块来实现。