ansible install docker / docker-compose centos

docker.yml

---

- name: Install Docker and Docker Compose on CentOS
  hosts: all
  become: true

  tasks:
    - name: Upgrade all packages
      yum: name=* state=latest

    - name: Check if Docker is installed
      command: systemctl status docker
      register: docker_check
      ignore_errors: yes

    - name: Download the Docker installer
      get_url:
        url: https://get.docker.com/
        dest: /root/install_docker.sh
        mode: 0700
      when: docker_check.stderr.find('service could not be found') != -1

    - name: Install Docker
      shell: /root/install_docker.sh
      when: docker_check.stderr.find('service could not be found') != -1


[root@localhost ~]# ansible-playbook docker.yml

PLAY [Install Docker and Docker Compose on CentOS] ************************************

TASK [Gathering Facts] ****************************************************************
The authenticity of host '192.168.1.7 (192.168.1.7)' can't be established.
ECDSA key fingerprint is SHA256:m8YpYiq0v1ChLkZk74cRLvjYcNwbQaMMjGnVvdox/7U.
ECDSA key fingerprint is MD5:7a:50:34:05:30:55:60:58:77:33:80:ff:76:e9:f1:f3.
Are you sure you want to continue connecting (yes/no)? yes
ok: [192.168.1.7]

TASK [Upgrade all packages] ***********************************************************
changed: [192.168.1.7]

TASK [Check if Docker is installed] ***************************************************
changed: [192.168.1.7]

TASK [Download the Docker installer] **************************************************
skipping: [192.168.1.7]

TASK [Install Docker] *****************************************************************
skipping: [192.168.1.7]

TASK [Remove the Docker installer file.] **********************************************
ok: [192.168.1.7]

TASK [Enable the Docker daemon in systemd] ********************************************
ok: [192.168.1.7]

TASK [Start the Docker daemon] ********************************************************
ok: [192.168.1.7]

TASK [Check if Docker Compose is installed] *******************************************
changed: [192.168.1.7]

TASK [Download and install Docker Compose] ********************************************
skipping: [192.168.1.7]

PLAY RECAP ****************************************************************************
192.168.1.7                : ok=7    changed=3    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0 

[root@localhost ~]#

Comments