Skip to content
Snippets Groups Projects
Commit a4450282 authored by Ryan Randles Jones's avatar Ryan Randles Jones
Browse files

Update terraform-ssh-remote-exec.tf

parent 6d29d79e
No related branches found
No related tags found
No related merge requests found
resource "openstack" "web" {
image = "CentOS-7-x86_64-GenericCloud-1905"
name = "ohpc"
region = "openstack"
size = "512mb"
ssh_keys = "${openstack_compute_keypair_v2.test-keypair.name}"
connection {
type = "ssh"
user = "root"
private_key = "${file("~/.ssh/id_rsa")}"
}
resource "ohpc" "vm" {
provisioner "remote-exec" {
inline = [
"hostnamectl set-hostname ohpc",
"yum install -y epel-release",
"yum install -y ansible git vim bash-completion",
"yum install -y NetworkManager",
"systemctl restart NetworkManager",
"nmcli con mod "Wired connection 1" connection.id "eth1""
]
connection {
host = "${self.ipv4_address}" # The `self` variable is like `this` in many programming languages
type = "ssh" # in this case, `self` is the resource (the server).
user = "root"
private_key = "${file('~/.ssh/id_rsa')}"
}
}
provisioner "local-exec" {
environment {
PUBLIC_IP = "${self.ipv4_address}"
PRIVATE_IP = "${self.ipv4_address_private}"
}
working_dir = "$HOME/terraform-first-instance/terraform-openstack/CRI_XCBC/"
command = "ansible-playbook -c local -i hosts -l `hostname` site.yaml -b,"
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment