Created
October 26, 2016 17:50
-
-
Save jtopjian/18d180e94955ec917e647175d2a86e2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "openstack_compute_keypair_v2" "workshop" { | |
name = "workshop" | |
public_key = "${file("key/id_rsa.pub")}" | |
} | |
resource "openstack_compute_secgroup_v2" "workshop" { | |
name = "workshop" | |
description = "Rules for workshop" | |
rule { | |
ip_protocol = "tcp" | |
from_port = 22 | |
to_port = 22 | |
cidr = "::/0" | |
} | |
rule { | |
ip_protocol = "tcp" | |
from_port = 80 | |
to_port = 80 | |
cidr = "::/0" | |
} | |
rule { | |
ip_protocol = "tcp" | |
from_port = 8889 | |
to_port = 8889 | |
cidr = "::/0" | |
} | |
} | |
resource "openstack_compute_instance_v2" "workshop" { | |
name = "workshop" | |
image_name = "devop-workshop" | |
flavor_name = "m1.small" | |
key_pair = "${openstack_compute_keypair_v2.workshop.name}" | |
security_groups = ["${openstack_compute_secgroup_v2.workshop.name}"] | |
connection { | |
user = "ubuntu" | |
host = "${openstack_compute_instance_v2.workshop.access_ip_v6}" | |
private_key = "${file("key/id_rsa")}" | |
} | |
provisioner "file" { | |
source = "key/id_rsa" | |
destination = "/home/ubuntu/.ssh/id_rsa" | |
} | |
provisioner "file" { | |
source = "key/id_rsa.pub" | |
destination = "/home/ubuntu/.ssh/id_rsa.pub" | |
} | |
provisioner "file" { | |
source = "files" | |
destination = "/home/ubuntu/files" | |
} | |
provisioner "remote-exec" { | |
inline = [ "bash /home/ubuntu/files/install.sh" ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment