Ansible Playbook for Installing Docker CE on Ubuntu 16.04

Ansible
2018-02-27 10:27 (6 years ago) ytyng

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?

Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011