-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
44 lines (34 loc) · 1008 Bytes
/
playbook.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
- hosts: localhost
tasks:
- name: Retrive Name of Docker Container
shell: "docker ps --format '{% raw %}{{ .Names }}{% endraw %}'"
register: Name
- name: Retreive Ip of Docker Container
shell: "docker inspect --format '{%raw %}{{ .NetworkSettings.IPAddress }}{% endraw %}' $(docker ps --format '{% raw %}{{ .Names }}{% endraw %}')"
register: IP
- name: Name of cont
debug:
var: Name.stdout
- name: IP of cont
debug:
var: IP.stdout
- name: upd inve
blockinfile:
path: /mydb/inventory.txt
block: |
{% raw %}[{% endraw %}{{ Name.stdout }}{%raw %}]{% endraw %}
{{ IP.stdout }} ansible_ssh_user=test ansible_ssh_pass=test
# CONFIGURATION OF webserver(apache2)
- hosts: NAME_OF_CONTAINER
become: yes
become_user: root
become_method: sudo
tasks:
- name: Installing webserver(apache2)
apt:
name: apache2
state: present
- name: Strating service
service:
name: apache2
state: started