-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdyanamic.yml
73 lines (58 loc) · 1.7 KB
/
dyanamic.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
- hosts: localhost
vars_prompt:
- name: container_name
prompt: "enter container name"
private: no
tasks:
- name : "configure yum for docker"
yum_repository:
name: "docker1-ce"
description: "docker1"
baseurl: "https://download.docker.com/linux/centos/7/x86_64/stable/"
gpgcheck: no
- name : "pip"
pip:
name: "docker"
- name: "Installing docker"
package:
name: "docker-ce-18.09.1-3.e17.x86_64"
state: present
- name: "STarting docker service"
service:
name: "docker"
state: started
- name: "Pulling docker image"
docker_image:
name: "httpd"
source: pull
- name: "Webpage"
copy:
src: test.html
dest: "/var/www/html"
- name: "Launch {{container_name}} container"
docker_container:
name: "{{container_name}}"
image: "httpd"
volumes: "/var/www/html:/usr/local/apache2/htdocs/"
# - name: "Container info"
# docker_container_info:
# name: "{{ container_name }}"
register: docker_info
- debug:
var: docker_info.ansible_facts.docker_container.NetworkSettings.IPAddress
- name: "Retriving ip dynamically "
template:
src: "docker.txt"
dest: "/root/ip.txt"
- hosts : docker
tasks:
- name: "Installing httpd"
package:
name: "httpd"
state: present
- name: " Webpage"
copy:
src: "test.html"
dest: "/var/www/html"
- name: "starting service"
command: "/usr/sbin/httpd"