2021-08-22 21:22:30 +02:00
|
|
|
local terraform = import "lib/terraform.libsonnet";
|
|
|
|
local config = import "config/config.libsonnet";
|
|
|
|
|
|
|
|
{
|
2021-10-03 19:04:37 +02:00
|
|
|
"terraform/terraform.tf.json": std.manifestJson({
|
2021-08-22 21:22:30 +02:00
|
|
|
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: {
|
2021-10-03 19:04:37 +02:00
|
|
|
[s]: config.servers[s].instance
|
|
|
|
for s in std.objectFields(config.servers)
|
2021-08-22 21:22:30 +02:00
|
|
|
},
|
|
|
|
hetznerdns_zone: {
|
|
|
|
infra: { name: config.infraDomain, ttl: config.defaultZoneTTL },
|
|
|
|
},
|
|
|
|
hetznerdns_record: std.foldl(function (a, b) a + b, [
|
2021-10-03 19:04:37 +02:00
|
|
|
terraform.serverDnsRecords(config.servers[s])
|
|
|
|
for s in std.objectFields(config.servers)
|
2021-08-22 21:22:30 +02:00
|
|
|
], {})
|
|
|
|
}
|
|
|
|
}),
|
2021-10-03 19:04:37 +02:00
|
|
|
"ansible/inventory.yaml": std.manifestYamlDoc({
|
2021-08-22 21:22:30 +02:00
|
|
|
all: {
|
|
|
|
hosts: {
|
2021-10-03 19:04:37 +02:00
|
|
|
[s]: config.servers[s] + {
|
|
|
|
ansible_host: config.servers[s].publicDomain,
|
2021-08-22 21:22:30 +02:00
|
|
|
ansible_user: "root"
|
|
|
|
}
|
2021-10-03 19:04:37 +02:00
|
|
|
for s in std.objectFields(config.servers)
|
2021-08-22 21:22:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
2021-10-03 19:04:37 +02:00
|
|
|
"ansible/site.yaml": std.manifestYamlDoc([
|
2021-08-22 21:22:30 +02:00
|
|
|
{
|
|
|
|
name: "Test command",
|
|
|
|
hosts: "all",
|
|
|
|
tasks: [
|
|
|
|
{
|
|
|
|
"ansible.builtin.command": "ls"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
])
|
|
|
|
}
|