-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-ansible.yml
58 lines (51 loc) · 1.51 KB
/
docker-ansible.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
---
- name: Configure docker on managed node then launch a contaienr and use that container as managed node.
hosts: dockernode
vars:
expose_port: 8080
ssh_port: 2222
tasks:
- block:
- name: yum repo for docker
yum_repository:
name: docker
description: "Repo for Docker"
file: docker_repo
baseurl: https://download.docker.com/linux/centos/7/x86_64/stable/
enabled: yes
state: present
gpgcheck: no
- name: install docker package
command: yum install -y docker-ce --nobest
when: ansible_distribution == "RedHat"
register: output
- name: start and enable docker service
service:
name: docker
state: started
enabled: yes
- name: firewall conf for docker
firewalld:
masquerade: yes
state: enabled
permanent: yes
zone: public
- name: enable firewall for docker port
firewalld:
port: "{{ item }}"
zone: public
permanent: yes
state: enabled
immediate: yes
loop:
- "80/tcp"
- "443/tcp"
- "{{ expose_port }}/tcp"
- name: reload firewall
service:
name: firewalld
state: reloaded
- name: restart docker service
service:
name: docker
state: restarted