forked from r3ap3rpy/ansibler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_install_docker.yaml
More file actions
67 lines (67 loc) · 1.65 KB
/
test_install_docker.yaml
File metadata and controls
67 lines (67 loc) · 1.65 KB
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
---
- hosts: centos
become: yes
gather_facts: no
tasks:
- name: Install dependencies for docker
yum:
name: ['lvm2','yum-utils','device-mapper-persistent-data']
state: latest
- name: Adding the docker repo
shell: |
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- name: Actually installing docker
yum:
name: ['docker-ce','docker-ce-cli','containerd.io']
state: latest
- name: Start and enable docker
service:
name: docker
state: started
enabled: yes
- name: Add ansible to the docker group
user:
name: ansible
group: docker
append: yes
- name: Download pip installer
get_url:
url: https://bootstrap.pypa.io/get-pip.py
dest: /tmp/get-pip.py
- name: Install pip
shell: |
/usr/bin/python /tmp/get-pip.py
- name: Install docker-py
pip:
name: docker-py
state: latest
- name: Set SELinux to permissive
selinux:
policy: targeted
state: permissive
- name: Copy docker file
copy:
src: docker/Dockerfile
dest: /home/ansible/Dockerfile
become_user: ansible
- name: Copy python app
copy:
src: docker/app.py
dest: /home/ansible/app.py
become_user: ansible
- name: Build the image
become_user: ansible
docker_image:
name: webapp
path: ~/
state: build
- name: Start the container
docker_container:
name: webapp
image: webapp
state: started
ports:
- "9999:9999"
- name: Check that you can connect (GET) to a page and it returns a status 200
uri:
url: "http://localhost:9999"