1、ansible管理机准备
yum install -y ansible
编辑hosts文件,连接测试 ansible all -m ping
下载仓储
wget -P /etc/yum.repos.d/ https://download.docker.com/linux/centos/docker-ce.repo
2、docker.yml
- hosts: dks
remote_user: root
tasks:
- name: setup yum-utils yum: name=yum-utils state=present
- name: setup device-mapper-persistent-data yum: name=device-mapper-persistent-data state=present
- name: setup lvm2 yum: name=lvm2 state=present
- name: cp docker.repo copy: src: "/etc/yum.repos.d/docker-ce.repo" dest: "/etc/yum.repos.d/docker-ce.repo"
- name: setup docker-ce yum: name=docker-ce state=present
- name: change shell: curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
- name: start docker service: name=docker.service enabled=yes state=started
3、执行:
ansible-playbook docker.yml
yml中忽略错误: ignore_errors: yes