zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    NSObject-拷贝 NSCopy-NSMutablecopy
    NSObject 排序
    iOS UIView上添加mp4视频
    OC语言中BOOL 和 bool 区别
    便利初始化浅析
    可变字符与不可不可变字符串的心得
    博客开通随笔
    OC总结第五讲:多态
    oc总结第四讲:属性
    oc总结第三讲 setter getter 方法 点运算符
  • 原文地址:https://www.cnblogs.com/chenyishi/p/14088466.html
Copyright © 2011-2022 走看看