#cloud-config
runcmd:
- curl -fsSL https://raw.githubusercontent.com/bauer-group/IAC-Ansible/main/scripts/install.sh | bashNot every provider supports cloud-init. For those, SSH into the freshly
installed box as root and run the installer with IAC_HOSTNAME set to the
matching inventory key:
curl -fsSL https://raw.githubusercontent.com/bauer-group/IAC-Ansible/main/scripts/install.sh | \
IAC_HOSTNAME=0047-20.cloud.bauer-group.com bashThe installer runs hostnamectl, updates /etc/hosts and writes
preserve_hostname: true to /etc/cloud/cloud.cfg before the first
ansible-pull, so the host finds its own host_vars/<name>.yml from
inventory. Idempotent — safe to re-run.
#cloud-config
# Set timezone
timezone: Etc/UTC
# Ensure prerequisites
packages:
- curl
- git
# Bootstrap IAC-Ansible
runcmd:
- |
curl -fsSL https://raw.githubusercontent.com/bauer-group/IAC-Ansible/main/scripts/install.sh | \
BRANCH=main \
SCHEDULE="*-*-* 02:00:00" \
bash
# Optional: Write custom host vars before first pull
write_files:
- path: /etc/iac-ansible-labels
content: |
cloud
production
permissions: '0644'resource "hcloud_server" "web" {
name = "0046-20"
server_type = "cx21"
image = "ubuntu-24.04"
user_data = <<-EOF
#cloud-config
runcmd:
- curl -fsSL https://raw.githubusercontent.com/bauer-group/IAC-Ansible/main/scripts/install.sh | bash
EOF
}hcloud server create \
--name 0046-20 \
--type cx21 \
--image ubuntu-24.04 \
--user-data-from-file cloud-init.ymlaws ec2 run-instances \
--image-id ami-xxxxx \
--instance-type t3.micro \
--user-data file://cloud-init.yml- The installer runs automatically on first boot
- Ansible is installed
ansible-pullis configured with systemd timer- Initial pull runs and applies the configuration
- Add the new host to
inventory/production/hosts.yml - Commit and push - server will pick up group assignments on next pull