new example scripts
This commit is contained in:
parent
0ec17ed585
commit
3805acf80f
46
terraform/triton/main.tf.tpl
Normal file
46
terraform/triton/main.tf.tpl
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
triton = {
|
||||||
|
source = "joyent/triton"
|
||||||
|
version = "0.8.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "triton" {
|
||||||
|
account = "username"
|
||||||
|
key_id = "key:id"
|
||||||
|
url = "https://eu-ro-1.api.spearhead.cloud"
|
||||||
|
key_material = "/path/to/id_rsa"
|
||||||
|
insecure_skip_tls_verify = false
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "triton_machine" "internal_resource_name" {
|
||||||
|
count = var.instance_count
|
||||||
|
name = "linux-${count.index + 1}"
|
||||||
|
package = "standard-2cpu-4ram-100disk"
|
||||||
|
image = "b70d5484-5168-4ecb-8127-0a0c59c1d906"
|
||||||
|
|
||||||
|
provisioner "file" {
|
||||||
|
source = "scripts/setup.sh"
|
||||||
|
destination = "/var/tmp/setup.sh"
|
||||||
|
}
|
||||||
|
|
||||||
|
provisioner "remote-exec" {
|
||||||
|
inline = [
|
||||||
|
"bash /var/tmp/setup.sh",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
connection {
|
||||||
|
type = "ssh"
|
||||||
|
host = self.primaryip
|
||||||
|
user = "ubuntu"
|
||||||
|
}
|
||||||
|
|
||||||
|
cns {
|
||||||
|
services = ["${var.service_name}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
18
terraform/triton/scripts/setup.sh
Normal file
18
terraform/triton/scripts/setup.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# add things youd like to do after provisioning here
|
||||||
|
|
||||||
|
# my_ip=`ip addr show net0 | grep -Po 'inet \K[\d.]+'`
|
||||||
|
# user_password=`openssl rand -base64 16`
|
||||||
|
# user="linux"
|
||||||
|
# sudo useradd -m -s /bin/bash -G sudo linux
|
||||||
|
# echo "linux:${user_password}" | sudo chpasswd
|
||||||
|
|
||||||
|
# sudo sed -i 's/\PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
|
# sudo sed -i 's/\ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/g' /etc/ssh/sshd_config
|
||||||
|
# sudo systemctl reload sshd
|
||||||
|
|
||||||
|
# echo "Linux password: ${user_password}" >> /var/tmp/.setup
|
||||||
|
# echo "IP: ${my_ip}" >> /var/tmp/.setup
|
||||||
|
# cat /var/tmp/.setup
|
||||||
|
|
11
terraform/triton/variables.tf.tpl
Normal file
11
terraform/triton/variables.tf.tpl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
variable "instance_count" {
|
||||||
|
description = "Number of triton instances to create"
|
||||||
|
type = number
|
||||||
|
default = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "service_name" {
|
||||||
|
type = string
|
||||||
|
description = "The name of the service in CNS."
|
||||||
|
default = "somename"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user