-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.yml
72 lines (61 loc) · 2.03 KB
/
docker.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#---
- hosts: all
become: true
gather_facts: true
tasks:
- name: Check if Docker is installed
register: docker_installed
command: docker -v
ignore_errors: true
- name: update the Linux system
apt:
upgrade=dist
register: upgrade
- name: Show the upgrade process
debug:
msg: "{{ upgrade.stdout }}"
- name: Remove the old version of docker
apt: name= {{ item }} state=absent
when: docker_installed is success
with_items:
- docker
- docker-io
- docker-ce
- name: Install the certificates on the machine
apt: name= {{ item }} state=latest
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
# - name: Add an apt key by id from a keyserver
# get_url:
# url: https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e
# dest: /home/deepak/Downloads/sks.key
# mode: 0440
- name: Add Docker’s official GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
# apt_key:
# id: 0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e
# url: https://sks-keyservers.net/pks/lookup?op=get&search=
# state: present
# uri:
# url: https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e
# return_content: yes
# register: aptkey
# - name: Add a key from a file on the Ansible server
# apt_key:
# data: "{{ lookup(aptkey) }}"
# state: present
- name: Add the repository for the docker
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu/dists/ $(lsb_release -cs) /stable
state: present
- name: Install Docker
apt: name=docker-ce state=latest
when: docker_installed is failed
- name: Display the Docker version installed
debug:
msg: "{{ docker_installed }}"