60 lines
1017 B
HCL
60 lines
1017 B
HCL
terraform {
|
|
required_providers {
|
|
system = {
|
|
version = "~> 0.0.1"
|
|
source = "dpedu/system"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
provider "system" {
|
|
connection_string = "ssh://root@core00?agent=yes"
|
|
// connection_string = "ssh://dave:password@core00"
|
|
// connection_string = "ssh://root@core00?ssh_key_path=~/.ssh/id_rsa"
|
|
}
|
|
|
|
|
|
# creates a directory
|
|
resource "system_dir" "confdir" {
|
|
path = "/srv/myapp"
|
|
mode = "0755"
|
|
owner = "root"
|
|
group = "root"
|
|
}
|
|
|
|
|
|
output "test" {
|
|
value = system_dir.confdir
|
|
}
|
|
|
|
|
|
# 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
|
|
}*/
|