Skip to content

Commit 3937e46

Browse files
committed
added in template for html page, changed inventory to yaml file, updated ansible provisioner to use that inventory file.
1 parent 2b49e15 commit 3937e46

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

ansible/httpd.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
---
2-
- hosts: all
2+
- hosts: http
33
become: yes
44
become_user: root
5+
6+
vars:
7+
helloworld: Meow!
8+
59
tasks:
610
- name: Stop firewalld
7-
service: name=firewalld state=stopped
11+
service:
12+
name: firewalld
13+
state: stopped
14+
815
- name: Install the httpd package
9-
yum: name=httpd
16+
yum:
17+
name: httpd
18+
1019
- name: Start the httpd service
11-
service: name=httpd state=started
20+
service:
21+
name: httpd
22+
state: started
23+
1224
- name: Configure Cat App
13-
script: ../files/webapp.sh
25+
template:
26+
src: ../files/index.j2
27+
dest: /var/www/html/index.html

ansible/inventory.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
http:
2+
hosts:
3+
ec2-13-57-34-111.us-west-1.compute.amazonaws.com:
4+
vars:
5+
ansible_ssh_user: centos
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#!/bin/sh
2-
3-
cat << EOM > /var/www/html/index.html
41
<html>
5-
<head><title>Meow!</title></head>
2+
<head><title>{{ helloworld }}</title></head>
63
<body style="background-image: linear-gradient(red,orange,yellow,green,blue,indigo,violet);">
74
<center><img src="http://placekitten.com/800/600"></img></center>
85
<marquee><h1>Meow World</h1></marquee>
96
</body>
10-
</html>
11-
EOM
12-
13-
echo "Your demo is now ready."
7+
</html>

terraform/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ resource "azurerm_virtual_machine" "site" {
122122
}
123123

124124
provisioner "local-exec" {
125-
command = "ansible-playbook -i '${azurerm_public_ip.tf-ansible-pip.fqdn},' --private-key ${var.ssh_key_path} ../ansible/httpd.yml"
125+
command = "ansible-playbook -i ../ansible/inventory.yaml --private-key ${var.ssh_key_path} ../ansible/httpd.yml"
126126
}
127127

128128
}

0 commit comments

Comments
 (0)