Skip to content

Commit a05a03d

Browse files
committed
Terraform now working with httpd.yml playbook.
1 parent 74dbea9 commit a05a03d

File tree

5 files changed

+29
-36
lines changed

5 files changed

+29
-36
lines changed

ansible/httpd.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- hosts: all
3+
become: yes
4+
become_user: root
5+
tasks:
6+
- name: Stop firewalld
7+
service: name=firewalld state=stopped
8+
- name: Install the httpd package
9+
yum: name=httpd
10+
- name: Start the httpd service
11+
service: name=httpd state=started
12+
- name: Configure Cat App
13+
script: ../files/webapp.sh

terraform/httpd.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

terraform/main.tf

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,20 @@ resource "azurerm_virtual_machine" "site" {
109109
}
110110
}
111111

112-
113-
114112
# This is to ensure SSH comes up before we run the local exec.
115-
provisioner "remote-exec" {
113+
provisioner "remote-exec" {
116114
inline = ["echo 'Hello World'"]
117115

118116
connection {
119117
type = "ssh"
120-
host = "${azurerm_public_ip.tf-ansible-pip.ip_address}"
118+
host = "${azurerm_public_ip.tf-ansible-pip.fqdn}"
121119
user = "${var.admin_username}"
122120
private_key = "${var.ssh_key}"
123121
}
124122
}
125123

126-
# TODO: have Dylan help with apache.yml playbook
127124
provisioner "local-exec" {
128-
command = "ansible-playbook -i '${azurerm_public_ip.tf-ansible-pip.ip_address},' --private-key ${var.ssh_key} httpd.yml"
125+
command = "ansible-playbook -i '${azurerm_public_ip.tf-ansible-pip.fqdn},' --private-key ${var.ssh_key_path} ../ansible/httpd.yml"
129126
}
130127

131128
}

terraform/outputs.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
# and include any data from the state file. Outputs are sorted alphabetically;
77
# use an underscore _ to move things to the bottom.
88

9-
# output "_instructions" {
10-
# value = "This output contains plain text. You can add variables too."
11-
# }
9+
output "_instructions" {
10+
value = "This output contains plain text. You can add variables too."
11+
}
1212

13-
# output "public_dns" {
14-
# value = "${azurerm_public_ip.tf-ansible-pip.fqdn}"
15-
# }
13+
output "public_dns" {
14+
value = "${azurerm_public_ip.tf-ansible-pip.fqdn}"
15+
}
1616

17-
# output "App_Server_URL" {
18-
# value = "http://${azurerm_public_ip.tf-ansible-pip.fqdn}"
19-
# }
17+
output "App_Server_URL" {
18+
value = "http://${azurerm_public_ip.tf-ansible-pip.fqdn}"
19+
}

terraform/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ variable "ssh_key" {
99
description = "SSH key for connecting to our Red Hat instance"
1010
}
1111

12+
variable "ssh_key_path" {
13+
description = "Path to your ssh key on the local system."
14+
}
15+
1216
variable "ssh_pubkey" {
1317
description = "Public half of SSH key for connecting to our Red Hat instance."
1418
}

0 commit comments

Comments
 (0)