local terraform = import "lib/terraform.libsonnet"; local config = import "config/config.libsonnet"; { "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.name]: s.instance for s in config.servers }, hetznerdns_zone: { infra: { name: config.infraDomain, ttl: config.defaultZoneTTL }, }, hetznerdns_record: std.foldl(function (a, b) a + b, [ terraform.serverDnsRecords(s) for s in config.servers ], {}) } }), "inventory.yaml": std.manifestYamlDoc({ all: { hosts: { [s.name]: s + { ansible_host: s.publicDomain, ansible_user: "root" } for s in config.servers } } }), "site.yaml": std.manifestYamlDoc([ { name: "Test command", hosts: "all", tasks: [ { "ansible.builtin.command": "ls" } ] } ]) }