본문 바로가기

Automation Tools/Ansible

8.5 ansible | [playbook] docker 설치

반응형

# docker-ce-20.10.5
---
- hosts: all
  become: yes
  tasks:
    - name: "yum install packages"
      yum:
        name: "{{ item }}"
        state: installed
      loop:
        - epel-release
        - yum-utils
        - git
    - name: "docker repo add"
      command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    - name: "docker install"
      yum:
        name: "{{ item }}"
        state: installed
      loop:
        - docker-ce-20.10.5
        - python3
        - python3-pip
        - bash-completion
    - name: "pip upgrade"
      command: pip3 install --upgrade pip
    - name: "docker-compose install"
      command: pip3 install docker-compose
    - name: "env PATH setting"
      lineinfile:
        dest: /etc/bashrc
        line: "{{ item }}"
        state: present
      with_items:
        - PATH=$PATH:/usr/local/bin
    - name: "systemctl docker enable"
      service:
        name: docker
        enabled: yes
    - name: "docker bash completion download"
      command: curl -o /opt/docker_completion.sh https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker
    - name: "docker bash completion env setting"
      lineinfile:
        dest: /etc/bashrc
        line: "{{ item }}"
        state: present
      with_items:
        - source /opt/docker_completion.sh
반응형