feat: provision ansible user with terraform #1
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
Terraform + Ansible setup for a self-hosted [Dokploy](https://dokploy.com/) instance.
|
||||
|
||||
## Setup
|
||||
## Terraform Setup
|
||||
|
||||
1. Create a Hetzner Cloud API key
|
||||
2. Create a Cloudflare DNS key with `Zone.DNS` edit permission
|
||||
@@ -74,3 +74,10 @@ env:
|
||||
TF_VAR_cloudflare_api_token: ${{ secrets.TF_VAR_CLOUDFLARE_API_TOKEN }}
|
||||
TF_VAR_domain_name: ${{ secrets.TF_VAR_DOMAIN_NAME }}
|
||||
```
|
||||
|
||||
## Ansible Setup
|
||||
|
||||
```yaml
|
||||
env:
|
||||
ANSIBLE_SSH_KEY: ${{ secrets.ANSIBLE_SSH_KEY }}
|
||||
```
|
||||
@@ -3,7 +3,7 @@
|
||||
- name: Setup dokploy machine
|
||||
hosts: all
|
||||
roles:
|
||||
- role: studio.ansible.base
|
||||
- role: studio.ansible.users
|
||||
- role: studio.ansible.security
|
||||
- role: studiovitali.ansible.base
|
||||
- role: studiovitali.ansible.users
|
||||
- role: studiovitali.ansible.security
|
||||
- role: dokploy
|
||||
@@ -1,7 +1,7 @@
|
||||
## ansible/requirements.yml
|
||||
|
||||
collections:
|
||||
- name: studio.ansible
|
||||
- name: studiovitali.ansible
|
||||
source: https://git.studiovita.li/studio/ansible.git ## HTTPS
|
||||
type: git
|
||||
version: dokploy
|
||||
+4
-2
@@ -10,7 +10,9 @@ resource "hcloud_server" "dokploy" {
|
||||
image = var.hcloud_image
|
||||
server_type = var.hcloud_server_type
|
||||
location = var.hcloud_location
|
||||
ssh_keys = [hcloud_ssh_key.ansible.id]
|
||||
user_data = templatefile("${path.module}/templates/user_data.tpl", {
|
||||
ssh_public_key = var.ssh_public_key
|
||||
})
|
||||
firewall_ids = [hcloud_firewall.host.id]
|
||||
|
||||
public_net {
|
||||
@@ -76,7 +78,7 @@ resource "cloudflare_dns_record" "subdomain" {
|
||||
|
||||
# Write IP to Ansible inventory
|
||||
resource "local_file" "ansible_inventory" {
|
||||
content = templatefile("${path.module}/../ansible/inventory.tpl", {
|
||||
content = templatefile("${path.module}/templates/ansible_inventory.tpl", {
|
||||
public_ip = local.public_ip
|
||||
})
|
||||
filename = "${path.module}/../ansible/inventory.ini"
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
# cloud-config
|
||||
users:
|
||||
- name: ansible
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
ssh_authorized_keys:
|
||||
- ${ssh_public_key}
|
||||
ssh_pwauth: false
|
||||
disable_root: true
|
||||
Reference in new issue
Block a user