69 lines
2.0 KiB
Plaintext
69 lines
2.0 KiB
Plaintext
local terraform = import "lib/terraform.libsonnet";
|
|
local config = import "config/config.libsonnet";
|
|
|
|
{
|
|
"terraform/terraform.tf.json": std.manifestJson({
|
|
terraform: {
|
|
required_providers: {
|
|
hcloud: {
|
|
source: "hetznercloud/hcloud",
|
|
version: "1.30.0"
|
|
},
|
|
hetznerdns: {
|
|
source: "timohirt/hetznerdns",
|
|
version: "1.1.1"
|
|
}
|
|
}
|
|
},
|
|
|
|
provider: {
|
|
hcloud: {
|
|
token: config.hcloudToken
|
|
},
|
|
hetznerdns: {
|
|
apitoken: config.hdnsToken
|
|
}
|
|
},
|
|
|
|
resource: {
|
|
hcloud_ssh_key: {
|
|
[k]: terraform.HcloudSSHKey { name: k, public_key: config.sshKeys[k] }
|
|
for k in std.objectFields(config.sshKeys)
|
|
},
|
|
hcloud_server: {
|
|
[s]: config.servers[s].instance
|
|
for s in std.objectFields(config.servers)
|
|
},
|
|
hetznerdns_zone: {
|
|
infra: { name: config.infraDomain, ttl: config.defaultZoneTTL },
|
|
},
|
|
hetznerdns_record: std.foldl(function (a, b) a + b, [
|
|
terraform.serverDnsRecords(config.servers[s])
|
|
for s in std.objectFields(config.servers)
|
|
], {})
|
|
}
|
|
}),
|
|
"ansible/inventory.yaml": std.manifestYamlDoc({
|
|
all: {
|
|
hosts: {
|
|
[s]: config.servers[s] + {
|
|
ansible_host: config.servers[s].publicDomain,
|
|
ansible_user: "root"
|
|
}
|
|
for s in std.objectFields(config.servers)
|
|
}
|
|
}
|
|
}),
|
|
"ansible/site.yaml": std.manifestYamlDoc([
|
|
{
|
|
name: "Test command",
|
|
hosts: "all",
|
|
tasks: [
|
|
{
|
|
"ansible.builtin.command": "ls"
|
|
}
|
|
]
|
|
}
|
|
])
|
|
}
|