Ansible Playbook for Installing Docker CE on Ubuntu 16.04

Ansible
2018-02-27 01:27 (8 years ago)
Ansible Playbook for Installing Docker CE on Ubuntu 16.04

Here's my attempt...

I used the following as a reference:

Installing Docker CE on Ubuntu - Qiita

---
- hosts: servers
  gather_facts: no
  become: yes
  tasks:

    - apt:
        name: apt-transport-https

    - apt:
        name: ca-certificates

    - apt:
        name: curl

    - apt:
        name: software-properties-common

    - shell: "apt list --installed |grep docker-ce"
      register: docker_ce_installed
      ignore_errors: True

    - when: docker_ce_installed|failed
      block:
        - shell: apt-key list Docker
          register: apt_key_exists

        - when: not apt_key_exists.stdout
          shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg |apt-key add -

        - shell: grep download.docker.com /etc/apt/sources.list
          register: apt_source_docker_exists
          ignore_errors: True

        - when: apt_source_docker_exists|failed
          shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

        - apt:
            update_cache: yes

        - apt:
            name: docker-ce

Does this look about right?

Please rate this article (No signup or login required)
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive