terraform-provider-system/examples/main.tf

52 lines
886 B
HCL

terraform {
required_providers {
system = {
version = "~> 0.0.1"
# source = "boilerplate-example.com/boilerplateprovider/boilerplate"
}
}
}
provider "system" {
host = "ssh://qux:baz@somehost?param=value&param2=value2"
}
# creates a directory
resource "system_dir" "confdir" {
path = "/srv/myapp"
mode = "0755"
owner = "root"
group = "root"
}
# creates a file
resource "system_file" "conffile" {
path = "${system_dir.confdir.path}/config.txt"
mode = "0644"
owner = "root"
group = "root"
content = <<EOF
lolol
lolol
lolol
EOF
}
# run a command once and store in the terraform state a boolean indicating that it has been ran
resource "system_exec" "install" {
command = "apt-get install -y myapp"
depends_on = [
system_file.conffile
]
}
output "install_log" {
value = system_exec.install.output
}