在 ubuntu 18.04 上,我正在运行这个 ansible(版本 2.5.1)角色:
---
- name: Add Docker apt repository key.
apt_key:
url: "https://download.docker.com/linux/ubuntu/gpg"
state: present
- name: gather facts
setup:
- name: Set the stable docker repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
state: present
update_cache: yes
- name: Install Docker
apt:
name: docker-ce
state: present
Run Code Online (Sandbox Code Playgroud)
有了这个剧本:
---
- hosts: localhost
connection: local
gather_facts: False
become: true
pre_tasks:
- name: Install python for Ansible
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
tasks:
- name: Install list of packages
apt: name={{item}} state=latest
with_items:
- nano
- git
- htop
- gitg
roles:
- {role: 'docker', tags: 'docker'}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
PLAY [localhost] *******************************************************************************************************************************
TASK [Install python for Ansible] **************************************************************************************************************
changed: [localhost]
TASK [docker : Add Docker apt repository key.] *************************************************************************************************
ok: [localhost]
TASK [docker : gather facts] *******************************************************************************************************************
ok: [localhost]
TASK [docker : Set the stable docker repository] ***********************************************************************************************
ok: [localhost]
TASK [docker : Install Docker] *****************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "No package matching 'docker-ce' is available"}
to retry, use: --limit @/home/user/repos/ansible-vps/src/ansible_create_workstation.retry
PLAY RECAP *************************************************************************************************************************************
localhost : ok=4 changed=1 unreachable=0 failed=1
Run Code Online (Sandbox Code Playgroud)
因此,由于某种原因无法找到 docker-ce 软件包,最近是否发生了变化,还是我做错了什么?
此外,当我查看:/etc/apt/sources.list它不包含:
deb [arch=amd64] https://download.docker.com/linux/ubuntu ...
Run Code Online (Sandbox Code Playgroud)
入口。
小智 6
您需要使用edge而不是stable与 bionic (18.04),它将来会处于稳定状态。
- name: Set the stable docker repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} edge"
state: present
update_cache: yes
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5146 次 |
| 最近记录: |