This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
/
docker-install.yml
57 lines (57 loc) · 1.75 KB
/
docker-install.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
- name: Install docker
become: yes
block:
- name: Install docker packages
apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- name: Add Docker s official GPG key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Verify that we have the key with the fingerprint
apt_key:
id: 0EBFCD88
state: present
- name: Set up the stable repository
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present
update_cache: yes
- name: Update apt packages
apt:
update_cache: yes
- name: Install docker
apt:
name: docker-ce
state: present
update_cache: yes
- name: Add remote "ubuntu" user to "docker" group
user:
name: ubuntu
groups: [ "docker" ]
append: yes
- name: Reset SSH connection (for "docker" group to be active)
meta:
reset_connection
- name: Install docker-compose
get_url:
url : https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-linux-x86_64
dest: /usr/local/bin/docker-compose
owner: ubuntu
group: docker
mode: 'u+x,g+x'
force: true
- name: Initialize single node swarm
block:
- name: Validate that server is manager node
shell: test $(docker info --format \{\{'.Swarm.ControlAvailable'\}\}) = true
rescue:
- name: Initialize single node swarm
command: docker swarm init --default-addr-pool 192.168.0.0/16 ## Default range may conflict with ec2 dns