-
Notifications
You must be signed in to change notification settings - Fork 0
/
Docker-01.yml
83 lines (64 loc) · 1.78 KB
/
Docker-01.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
73
74
75
76
77
78
79
80
81
82
83
1. Ïîñòðîåíèå êîíòåéíåðîâ c Dockerfile.
Dockerfile:
##################################
FROM docker.io/fedora:29
RUN dnf install -y cowsay nginx
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN cowsay boop > /usr/share/nginx/html/index.html
EXPOSE 80
CMD /usr/sbin/nginx
##################################
---
- name: build an image
hosts: localhost
gather_facts: false
tasks:
- name: build that image
docker_image:
path: .
state: present
name: fedora-moo
- name: start the container
docker_container:
name: playbook-container
image: fedora-moo
ports: 8080:80
state: started
##################################
No root: curl http://localhost:8080
##################################
2. Ïîñòðîåíèå êîíòåéíåðîâ áåç Dockerfile.
---
- name: build an image
hosts: localhost
gather_facts: false
tasks:
- name: start the container
docker_container:
name: playbook-container
image: docker.io/fedora:29
ports: 8080:80
state: started
command: sleep 500
- name: make a host
add_host:
name: playbook-container
ansible_connection: docker
ansible_ssh_user: root
- name: do things
hosts: playbook-container
gather_facts: false
tasks:
- name: install things
raw: dnf install -y python-dnf
- name: install things
dnf:
name: ['nginx', 'cowsay']
- name: configure nginx
lineinfile:
line: "daemon off;"
dest: /etc/nginx/nginx.conf
- name: boop
shell: cowsay boop > /usr/share/nginx/html/index.html
- name: run nginx
shell: nginx &