111111

ansible配置docker

目录

[root@db1 server]# tree . ├── ans-docker │   ├── dockerfile │   └── hosts ├── group_vars │   └── all ├── hosts ├── sys_basic │   ├── ~ │   ├── files │   │   ├── daemon.json │   │   └── hosts │   ├── handlers │   ├── tasks │   │   └── main.yml │   └── templates └── top.yml

  

top.yml


- hosts: db
  vars:
    python_interpreter: /usr/bin/python2
  roles:
    - role: sys_basic



- hosts: db
  vars:
    python_interpreter: /usr/bin/python3

  

daemon.json 

{
  "registry-mirrors": ["https://docker-proxy.741001.xyz","https://registry.docker-cn.com"]
}

  

[root@db1 server]# cat  sys_basic/tasks/main.yml 
- name: 1yum安装
  yum:
    name:
      - tree
      - vim
      - wget
      - bash-completion
      - bash-completion-extras
      - lrzsz 
      - net-tools
      - unzip
      - bind-utils
      - httpd-tools
      - telnet
      - python3-pip


- name:  pei hos
  copy:
    src: hosts
    dest: /etc/hosts
    backup: yes


- name: 3.安装oython3 docker依赖
  command: pip3 install docker==2.6.1


- name: 4.开启内核转发
  shell: 
    cmd:
      echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
      sysctl -p 

- name: 5 安装docker-ce,docker-compose 源
  get_url: 
    url: https://mirrors.aliyun.com/repo/Centos-7.repo
    dest: /etc/yum.repos.d/CentOS-Base.repo
    validate_certs: no

- name: 6 安装
  yum:
    name: 
      - docker-ce
      - docker-compose 
      

- name: 6 pez docke加速
  copy:
    src: daemon.json
    dest: /etc/docker/daemon.json
    backup: yes


- name: 7 qidong
  systemd:
    name: docker
    enabled: yes
    state: started

  

posted @ 2024-11-28 11:20  赵SIR  阅读(2)  评论(0编辑  收藏  举报