首页 > 其他 > 详细

docker-install-v0.1-alpha

时间:2019-12-28 10:23:14      阅读:84      评论:0      收藏:0      [点我收藏+]

docker-install-v0.1-alpha/
├── inventory
├── roles
│ └── docker
│ ├── defaults
│ │ └── main.yml
│ ├── files
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── README.md
│ ├── tasks
│ │ └── main.yml
│ ├── templates
│ │ └── daemon.json.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ └── main.yml
└── setup.yml


setup.yml

- name: Install Docker
  hosts: all
  gather_facts: no
  vars:
    registry_accelerator: 
      url: "阿里云镜像加速器地址"

    yum_repository:
      base_repo:
        name: "CentOS-Base.repo"
        url: "http://mirrors.aliyun.com/repo/Centos-7.repo"
      epel_repo:
        name: "epel.repo"
        url: "http://mirrors.aliyun.com/repo/epel-7.repo"
      docker_repo:
        name: "docker-ce.repo"
        url: "https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo"
  roles:
    - docker

roles/docker/tasks/main.yml

---
# tasks file for docker
- name: Add yum repository
  get_url:
    url: "{{ item.value.url }}"
    dest: "/etc/yum.repos.d/{{ item.value.name }}"
  loop: "{{ yum_repository | dict2items }}"

- name: Install docker-ce
  yum:
    name: docker-ce
    state: present

- name: Create /etc/docker directory
  file:
     path: /etc/docker
     state: directory
     mode: '0755'

- name: Create docker configuration file
  template:
    src: daemon.json.j2
    dest: /etc/docker/daemon.json
  notify:
    - restart docker

- name: Start and enable docker
  systemd:
    name: docker
    state: started
    enabled: yes

roles/docker/templates/daemon.json.j2

{
    "registry-mirrors": ["{{ registry_accelerator.url }}"]
}

roles/docker/handlers/main.yml

---
# handlers file for docker
- name: restart docker
  systemd:
    name: docker
    state: restarted 

docker-install-v0.1-alpha

原文:https://www.cnblogs.com/zakzhu/p/12110876.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!