diff --git a/instance_scripts/cloud-init.yml b/instance_scripts/cloud-init.yml new file mode 100644 index 0000000000000000000000000000000000000000..ed69de7de41268141bdf264db47f2709a5e0fb64 --- /dev/null +++ b/instance_scripts/cloud-init.yml @@ -0,0 +1,9 @@ +#cloud-config + +package_update: true +package_upgrade: true + +runcmd: + - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" + - "source \"$HOME/.cargo/env\"" + diff --git a/terraform/main.tf b/terraform/main.tf index 26561465b58c0c207d9c50f14f6fa1f8fe4530c9..0abafa24721bf1e9c4508d1308cc4a7aa5b53fdc 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -82,42 +82,47 @@ resource "scaleway_instance_server" "user_instance_server" { ip_id = scaleway_instance_ip.public_ip[count.index].id security_group_id = scaleway_instance_security_group.www.id + user_data = { + foo = "bar" + cloud-init = file("../instance_scripts/cloud-init.yml") + } + depends_on = [ scaleway_account_ssh_key.ssh_key, scaleway_instance_security_group.www ] } -resource "null_resource" "provisioner" { - count = var.INSTANCES_COUNT - depends_on = [ - scaleway_instance_server.user_instance_server - ] - - connection { - host = element(scaleway_instance_ip.public_ip.*.address, count.index) - type = "ssh" - user = "root" - private_key = var.SCW_SSH_PRIVATE_KEY - timeout = "2m" - } - - // Install Rust - provisioner "remote-exec" { - inline = [ - "apt-get update -y'", - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y'", - "source \"$HOME/.cargo/env\"", - ] - } - - // Install Code-server - provisioner "remote-exec" { - inline = [ - "curl -fsSL https://code-server.dev/install.sh | sh", - "mkdir -p /root/.config/code-server/", - "echo 'bind-addr: 0.0.0.0:8080\nauth: password\npassword: yfB4W23G\ncert: false\n' > /root/.config/code-server/config.yaml", - "systemctl enable --now code-server@$USER" - ] - } -} \ No newline at end of file +#resource "null_resource" "provisioner" { +# count = var.INSTANCES_COUNT +# depends_on = [ +# scaleway_instance_server.user_instance_server +# ] +# +# connection { +# host = element(scaleway_instance_ip.public_ip.*.address, count.index) +# type = "ssh" +# user = "root" +# private_key = var.SCW_SSH_PRIVATE_KEY +# timeout = "2m" +# } +# +# // Install Rust +# provisioner "remote-exec" { +# inline = [ +# "apt-get update -y'", +# "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y'", +# "source \"$HOME/.cargo/env\"", +# ] +# } +# +# // Install Code-server +# provisioner "remote-exec" { +# inline = [ +# "curl -fsSL https://code-server.dev/install.sh | sh", +# "mkdir -p /root/.config/code-server/", +# "echo 'bind-addr: 0.0.0.0:8080\nauth: password\npassword: yfB4W23G\ncert: false\n' > /root/.config/code-server/config.yaml", +# "systemctl enable --now code-server@$USER" +# ] +# } +#} \ No newline at end of file