From 99550a76d0afba45da117bce408201c317eaadc1 Mon Sep 17 00:00:00 2001 From: Patrick Cao Huu Thien Date: Mon, 28 Nov 2022 15:06:16 +0100 Subject: [PATCH] module alpine postinstall --- .gitignore | 0 main.tf | 29 +++++++++++++++++++++++++++++ variables.tf | 11 +++++++++++ 3 files changed, 40 insertions(+) create mode 100644 .gitignore create mode 100644 main.tf create mode 100644 variables.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..b62d12a --- /dev/null +++ b/main.tf @@ -0,0 +1,29 @@ +## NEED a provider +# use in root module: +# +# module "postinstall" { +# source "../alpine_postinstall" +# connexion_ip = var.eth0_ip +# connexion_private_key = var.pm_private_key +# } + +resource "null_resource" "alpine_postinstall" { + connection { + type = "ssh" + user = "root" + host = var.connection_ip + private_key = var.connection_private_key + } + provisioner "remote-exec" { + inline = [ + # see https://git.alpinelinux.org/aports/tree/main/ + "echo '#--------------------------'", + "echo '# module alpine_postinstall'", + "echo '#--------------------------'", + "apk add file man-pages tzdata bash htop vim", + "apk add openssh-server", + "echo '# module DONE'", + ] + } +} + diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..22e84dc --- /dev/null +++ b/variables.tf @@ -0,0 +1,11 @@ +variable "connection_ip" { + type = string + description = "ipv4" +} + +variable "connection_private_key" { + type = string + description = "private key used by terraform" + sensitive = true +} +