打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ansible playbook 安装docker

1.新增host配置到/etc/ansible/hosts文件中

[docker]
192.168.43.95

2.配置无密码登录

# 配置ssh,默认rsa加密,保存目录(公钥)~/.ssh/id_rsa.pub
ssh-keygen -t rsa

# 配置无密码登陆,这里需要分别4次发送至4台服务器
ssh-copy-id -i ~/.ssh/id_rsa.pub root@ip

3.编写playbook

---
- hosts: docker
  remote_user: root
  tasks:
    - name: install yum-utils
      yum: name=yum-utils state=present
    - name: add docker repo
      shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    - name: install docer-ce
      yum:
        name: docker-ce
        state: present
    - name: install docker-ce-cli
      yum:
        name: docker-ce-cli
        state: present
    - name: install containerd.io
      yum:
        name: containerd.io
        state: present
    - name: config mirro
      copy: src=~/docker-daemon.json dest=/etc/docker/daemon.json
      tags: configmirro
    - name: start enable docker
      service: name=docker state=started enabled=true
    - name: restrat
      shell: sudo systemctl daemon-reload && sudo systemctl restart docker
      tags: restart

mirror配置

[root@localhost ~]# cat docker-daemon.json
{
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}

 

4.运行playbook

 ansible-playbook -v install_docker-ce.yml

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
docker部署zabbix ansile批量部署自动发现
ansible安装docker脚本
Ansible
ansible 笔记
Ansible超详细使用指南
记录下在CentOS7中安装Docker CE
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服