Skip to content

Commit 74dbea9

Browse files
committed
Updated names, trying to fix provisioner.
1 parent 0a82b83 commit 74dbea9

File tree

5 files changed

+41
-15
lines changed

5 files changed

+41
-15
lines changed

terraform/apache.yml

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

terraform/httpd.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- hosts: webapp
3+
sudo: yes
4+
tasks:
5+
- name: install httpd
6+
yum: name=httpd
7+
- name: start the httpd service
8+
service: name=httpd state=started
9+
- name: Configure CatApp
10+
shell: |
11+
cmd: |
12+
cat << EOM > /var/www/html/index.html
13+
<html>
14+
<head><title>Meow!</title></head>
15+
<body style="background-image: linear-gradient(red,orange,yellow,green,blue,indigo,violet);">
16+
<center><img src="http://placekitten.com/800/600"></img></center>
17+
<marquee><h1>Meow World</h1></marquee>
18+
</body>
19+
</html>
20+
EOM
21+
echo "Your kitten is ready."

terraform/main.tf

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resource "azurerm_subnet" "subnet" {
2020
address_prefix = "${var.subnet_prefix}"
2121
}
2222

23-
resource "azurerm_network_security_group" "tf-guide-sg" {
23+
resource "azurerm_network_security_group" "tf-ansible-sg" {
2424
name = "${var.prefix}-sg"
2525
location = "${var.location}"
2626
resource_group_name = "${azurerm_resource_group.terraform_ansible.name}"
@@ -50,21 +50,21 @@ resource "azurerm_network_security_group" "tf-guide-sg" {
5050
}
5151
}
5252

53-
resource "azurerm_network_interface" "tf-guide-nic" {
54-
name = "${var.prefix}tf-guide-nic"
53+
resource "azurerm_network_interface" "tf-ansible-nic" {
54+
name = "${var.prefix}tf-ansible-nic"
5555
location = "${var.location}"
5656
resource_group_name = "${azurerm_resource_group.terraform_ansible.name}"
57-
network_security_group_id = "${azurerm_network_security_group.tf-guide-sg.id}"
57+
network_security_group_id = "${azurerm_network_security_group.tf-ansible-sg.id}"
5858

5959
ip_configuration {
6060
name = "${var.prefix}ipconfig"
6161
subnet_id = "${azurerm_subnet.subnet.id}"
6262
private_ip_address_allocation = "Dynamic"
63-
public_ip_address_id = "${azurerm_public_ip.tf-guide-pip.id}"
63+
public_ip_address_id = "${azurerm_public_ip.tf-ansible-pip.id}"
6464
}
6565
}
6666

67-
resource "azurerm_public_ip" "tf-guide-pip" {
67+
resource "azurerm_public_ip" "tf-ansible-pip" {
6868
name = "${var.prefix}-ip"
6969
location = "${var.location}"
7070
resource_group_name = "${azurerm_resource_group.terraform_ansible.name}"
@@ -78,7 +78,7 @@ resource "azurerm_virtual_machine" "site" {
7878
resource_group_name = "${azurerm_resource_group.terraform_ansible.name}"
7979
vm_size = "${var.vm_size}"
8080

81-
network_interface_ids = ["${azurerm_network_interface.tf-guide-nic.id}"]
81+
network_interface_ids = ["${azurerm_network_interface.tf-ansible-nic.id}"]
8282
delete_os_disk_on_termination = "true"
8383

8484
storage_image_reference {
@@ -109,14 +109,23 @@ resource "azurerm_virtual_machine" "site" {
109109
}
110110
}
111111

112+
113+
112114
# This is to ensure SSH comes up before we run the local exec.
113115
provisioner "remote-exec" {
114116
inline = ["echo 'Hello World'"]
117+
118+
connection {
119+
type = "ssh"
120+
host = "${azurerm_public_ip.tf-ansible-pip.ip_address}"
121+
user = "${var.admin_username}"
122+
private_key = "${var.ssh_key}"
123+
}
115124
}
116125

117126
# TODO: have Dylan help with apache.yml playbook
118127
provisioner "local-exec" {
119-
command = "ansible-playbook -i '${self.public_ip},' --private-key ${var.ssh_key} apache.yml"
128+
command = "ansible-playbook -i '${azurerm_public_ip.tf-ansible-pip.ip_address},' --private-key ${var.ssh_key} httpd.yml"
120129
}
121130

122131
}

terraform/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# }
1212

1313
# output "public_dns" {
14-
# value = "${azurerm_public_ip.tf-guide-pip.fqdn}"
14+
# value = "${azurerm_public_ip.tf-ansible-pip.fqdn}"
1515
# }
1616

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

terraform/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ variable "ssh_pubkey" {
1515

1616
variable "resource_group" {
1717
description = "The name of your Azure Resource Group."
18-
default = "Terraform-Azure-Beginners"
18+
default = "Terraform-Ansible"
1919
}
2020

2121
variable "prefix" {

0 commit comments

Comments
 (0)