-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocker_host_setup.yaml
61 lines (52 loc) · 1.4 KB
/
docker_host_setup.yaml
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
---
## retreive dynamic settings information at the Ansible Controller
## on the remote host
- hosts: appcontainers
remote_user: ubuntu
become: yes
become_method: sudo
gather_facts: yes
tasks:
# add the docker repo
- name: Import docker CE repository key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: add Docker ce repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: update the apt cache
apt:
update_cache: yes
- name: list versions available
shell: apt-cache show docker-ce
register: docker_versions
- name: install docker community edition
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- docker-ce
- name: setup docker daemon
copy:
src: "{{playbook_dir}}/docker_daemon.json"
dest: /etc/docker/daemon.json
# https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant/
- name: Remove swapfile from /etc/fstab
mount:
name: "{{ item }}"
fstype: swap
state: absent
with_items:
- swap
- none
- name: Disable swap
command: swapoff -a
# when: ansible_swaptotal_mb > 0
- name: restart docker daemon
service:
name: docker
state: restarted