Compare commits
5 Commits
main
...
feat/add-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
79b37f17e2
|
|||
|
7f36507dce
|
|||
|
767fd3b503
|
|||
|
5f2b51ef09
|
|||
|
909fd105e7
|
17
Taskfile.yml
17
Taskfile.yml
@@ -8,7 +8,8 @@ tasks:
|
|||||||
|
|
||||||
vault: ansible-vault edit vault.yml {{.CLI_ARGS}}
|
vault: ansible-vault edit vault.yml {{.CLI_ARGS}}
|
||||||
provision: ansible-playbook playbooks/provision.yml {{.CLI_ARGS}}
|
provision: ansible-playbook playbooks/provision.yml {{.CLI_ARGS}}
|
||||||
deploy: ansible-playbook playbooks/deploy.yml {{.CLI_ARGS}}
|
deploy:gitea: ansible-playbook playbooks/deploy.yml {{.CLI_ARGS}}
|
||||||
|
deploy:runner: ansible-playbook playbooks/runner.yml {{.CLI_ARGS}}
|
||||||
restore: ansible-playbook playbooks/restore.yml {{.CLI_ARGS}}
|
restore: ansible-playbook playbooks/restore.yml {{.CLI_ARGS}}
|
||||||
|
|
||||||
assets:
|
assets:
|
||||||
@@ -18,9 +19,13 @@ tasks:
|
|||||||
- cp ./assets/logo.svg ./gitea/custom/public/assets/img/favicon.svg
|
- cp ./assets/logo.svg ./gitea/custom/public/assets/img/favicon.svg
|
||||||
- cp ./assets/logo.png ./gitea/custom/public/assets/img/apple-touch-icon.png
|
- cp ./assets/logo.png ./gitea/custom/public/assets/img/apple-touch-icon.png
|
||||||
|
|
||||||
|
enter:gitea:
|
||||||
enter:
|
cmd: ssh {{.GITEA}}
|
||||||
cmd: ssh -i {{.KEY}} -p 2222 root@{{.IP}}
|
|
||||||
vars:
|
vars:
|
||||||
KEY: { sh: ansible-vault view vault.yml | yq -r ".secret.private_ssh_key_path" }
|
GITEA: { sh: cat ./variables.yml | yq -r ".variables.gitea_host" }
|
||||||
IP: { sh: cat dist/terraform_outputs.yml | jq -r ".server_ip.value" }
|
|
||||||
|
enter:runner:
|
||||||
|
cmd: ssh -J {{.GITEA}} {{.RUNNER}}
|
||||||
|
vars:
|
||||||
|
GITEA: { sh: cat ./variables.yml | yq -r ".variables.gitea_host" }
|
||||||
|
RUNNER: { sh: cat ./variables.yml | yq -r ".variables.runner_host" }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
ansible_ssh_host: "{{ server_ip.value }}"
|
ansible_ssh_host: "{{ server_ip.value }}"
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
ansible_port: 22
|
ansible_port: 22
|
||||||
ansible_private_key_file: "{{ secret.private_ssh_key_path }}"
|
ansible_private_key_file: "{{ secret.private_gitea_ssh_key_path }}"
|
||||||
|
|
||||||
- name: Switch port to 2222.
|
- name: Switch port to 2222.
|
||||||
hosts: server_fresh
|
hosts: server_fresh
|
||||||
@@ -41,10 +41,7 @@
|
|||||||
- name: Add remote host.
|
- name: Add remote host.
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: server
|
name: server
|
||||||
ansible_ssh_host: "{{ server_ip.value }}"
|
ansible_ssh_host: "{{ variables.gitea_host }}"
|
||||||
ansible_user: root
|
|
||||||
ansible_port: 2222
|
|
||||||
ansible_private_key_file: "{{ secret.private_ssh_key_path }}"
|
|
||||||
|
|
||||||
- name: Install Docker.
|
- name: Install Docker.
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
@@ -55,10 +52,10 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- name: Install PIP.
|
- name: Install PIP.
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
name:
|
name:
|
||||||
- python3-pip
|
- python3-pip
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
- name: Install needed packages.
|
- name: Install needed packages.
|
||||||
ansible.builtin.pip:
|
ansible.builtin.pip:
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
project_path: '../terraform'
|
project_path: '../terraform'
|
||||||
state: "planned"
|
state: "planned"
|
||||||
plan_file: plan.out
|
plan_file: plan.out
|
||||||
init_reconfigure: true
|
# init_reconfigure: true
|
||||||
force_init: true
|
|
||||||
backend_config: "{{ terraform.backend }}"
|
backend_config: "{{ terraform.backend }}"
|
||||||
variables: "{{ terraform.variables }}"
|
variables: "{{ terraform.variables }}"
|
||||||
complex_vars: true
|
complex_vars: true
|
||||||
@@ -37,3 +36,31 @@
|
|||||||
content: "{{ terraform_apply.outputs }}"
|
content: "{{ terraform_apply.outputs }}"
|
||||||
dest: ../dist/terraform_outputs.yml
|
dest: ../dist/terraform_outputs.yml
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Update SSH config.
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
tags: hosts
|
||||||
|
vars_files:
|
||||||
|
- ../vault.yml
|
||||||
|
- ../dist/terraform_outputs.yml
|
||||||
|
- ../variables.yml
|
||||||
|
tasks:
|
||||||
|
- name: Add Gitea host.
|
||||||
|
community.general.ssh_config:
|
||||||
|
host: "{{ variables.gitea_host }}"
|
||||||
|
hostname: "{{ server_ip.value }}"
|
||||||
|
remote_user: root
|
||||||
|
forward_agent: true
|
||||||
|
user: user
|
||||||
|
port: 2222
|
||||||
|
identity_file: "{{ secret.private_gitea_ssh_key_path }}"
|
||||||
|
|
||||||
|
- name: Add Runner host.
|
||||||
|
community.general.ssh_config:
|
||||||
|
host: "{{ variables.runner_host }}"
|
||||||
|
remote_user: root
|
||||||
|
user: user
|
||||||
|
identity_file: "{{ secret.private_runner_ssh_key_path }}"
|
||||||
|
proxyjump: "{{ variables.gitea_host }}"
|
||||||
|
hostname: 10.0.10.17
|
||||||
|
|||||||
@@ -8,10 +8,7 @@
|
|||||||
- name: Add remote host.
|
- name: Add remote host.
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: server
|
name: server
|
||||||
ansible_ssh_host: "{{ server_ip.value }}"
|
ansible_ssh_host: "{{ variables.gitea_host }}"
|
||||||
ansible_user: root
|
|
||||||
ansible_port: 2222
|
|
||||||
ansible_private_key_file: "{{ secret.private_ssh_key_path }}"
|
|
||||||
|
|
||||||
- name: Deploy artifact to instance.
|
- name: Deploy artifact to instance.
|
||||||
hosts: server
|
hosts: server
|
||||||
@@ -33,10 +30,10 @@
|
|||||||
object: "{{ secret.restore.key | mandatory(msg='You must specify the key of the data.') }}"
|
object: "{{ secret.restore.key | mandatory(msg='You must specify the key of the data.') }}"
|
||||||
dest: /root/snapshot.tar.gz
|
dest: /root/snapshot.tar.gz
|
||||||
mode: get
|
mode: get
|
||||||
|
endpoint_url: "{{ secret.restore.endpoint }}"
|
||||||
region: "{{ secret.restore.region }}"
|
region: "{{ secret.restore.region }}"
|
||||||
access_key: "{{ secret.restore.access_key }}"
|
access_key: "{{ secret.restore.access_key }}"
|
||||||
secret_key: "{{ secret.restore.secret_key }}"
|
secret_key: "{{ secret.restore.secret_key }}"
|
||||||
endpoint_url: "{{ secret.restore.endpoint | mandatory(msg='You must specify the S3 URL.') }}"
|
|
||||||
ignore_nonexistent_bucket: true
|
ignore_nonexistent_bucket: true
|
||||||
|
|
||||||
- name: Ensure backup directory exists.
|
- name: Ensure backup directory exists.
|
||||||
|
|||||||
113
playbooks/runner.yml
Normal file
113
playbooks/runner.yml
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
- name: Set up for fresh host.
|
||||||
|
gather_facts: false
|
||||||
|
hosts: localhost
|
||||||
|
vars_files:
|
||||||
|
- ../vault.yml
|
||||||
|
- ../variables.yml
|
||||||
|
tasks:
|
||||||
|
- name: Add runner host.
|
||||||
|
ansible.builtin.add_host:
|
||||||
|
name: runner
|
||||||
|
ansible_ssh_host: "{{ variables.runner_host }}"
|
||||||
|
ansible_ssh_extra_args: "-J {{ variables.gitea_host }}"
|
||||||
|
|
||||||
|
- name: Add Gitea host.
|
||||||
|
ansible.builtin.add_host:
|
||||||
|
name: gitea
|
||||||
|
ansible_ssh_host: "{{ variables.gitea_host }}"
|
||||||
|
|
||||||
|
- name: Install Docker.
|
||||||
|
gather_facts: true
|
||||||
|
hosts: runner
|
||||||
|
vars_files:
|
||||||
|
- ../vault.yml
|
||||||
|
- ../dist/terraform_outputs.yml
|
||||||
|
tasks:
|
||||||
|
- name: Install PIP.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- python3-pip
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Install needed packages.
|
||||||
|
ansible.builtin.pip:
|
||||||
|
name:
|
||||||
|
- botocore
|
||||||
|
- boto3
|
||||||
|
- packaging
|
||||||
|
state: present
|
||||||
|
break_system_packages: true
|
||||||
|
|
||||||
|
- name: Download Docker repository key.
|
||||||
|
ansible.builtin.apt_key:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Download Docker repository.
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: "deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Remove bad packages.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: absent
|
||||||
|
package:
|
||||||
|
- docker.io
|
||||||
|
- docker-doc
|
||||||
|
- docker-compose
|
||||||
|
- podman-docker
|
||||||
|
- containerd
|
||||||
|
- runc
|
||||||
|
|
||||||
|
- name: Download Docker dependencies.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: present
|
||||||
|
package:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
|
||||||
|
- name: Download Docker packages.
|
||||||
|
ansible.builtin.apt:
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
package:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-buildx-plugin
|
||||||
|
- docker-compose-plugin
|
||||||
|
|
||||||
|
- name: Get registration token for Runner.
|
||||||
|
hosts: gitea
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Get registration token.
|
||||||
|
community.docker.docker_container_exec:
|
||||||
|
container: server
|
||||||
|
command: gitea actions grt
|
||||||
|
register: output
|
||||||
|
|
||||||
|
- name: Set fact.
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
registration_token: "{{ output.stdout }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
delegate_facts: true
|
||||||
|
|
||||||
|
- name: Deploy Runner.
|
||||||
|
hosts: runner
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
- name: Deploy image.
|
||||||
|
community.docker.docker_container:
|
||||||
|
name: runner
|
||||||
|
image: docker.io/gitea/act_runner:nightly
|
||||||
|
env:
|
||||||
|
CONFIG_FILE: /config.yaml
|
||||||
|
GITEA_INSTANCE_URL: git.maximhutz.com
|
||||||
|
GITEA_RUNNER_REGISTRATION_TOKEN: "{{ hostvars['localhost']['registration_token'] }}"
|
||||||
|
GITEA_RUNNER_NAME: "Main Runner"
|
||||||
|
volumes:
|
||||||
|
- ./config.yaml:/config.yaml
|
||||||
|
- ./data:/data
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
63
terraform/.terraform.lock.hcl
generated
63
terraform/.terraform.lock.hcl
generated
@@ -2,44 +2,45 @@
|
|||||||
# Manual edits may be lost in future updates.
|
# Manual edits may be lost in future updates.
|
||||||
|
|
||||||
provider "registry.terraform.io/hashicorp/aws" {
|
provider "registry.terraform.io/hashicorp/aws" {
|
||||||
version = "6.27.0"
|
version = "6.12.0"
|
||||||
hashes = [
|
hashes = [
|
||||||
"h1:emgTfB1LXSFYh9uAwgsRMoMIN5Wz7jNNKq3rqC0EHWk=",
|
"h1:8u90EMle+I3Auh4f/LPP6fEfRsAF6xCFnUZF4b7ngEs=",
|
||||||
"zh:177a24b806c72e8484b5cabc93b2b38e3d770ae6f745a998b54d6619fd0e8129",
|
"zh:054bcbf13c6ac9ddd2247876f82f9b56493e2f71d8c88baeec142386a395165d",
|
||||||
"zh:4ac4a85c14fb868a3306b542e6a56c10bd6c6d5a67bc0c9b8f6a9060cf5f3be7",
|
"zh:195489f16ad5621db2cec80be997d33060462a3b8d442c890bef3eceba34fa4d",
|
||||||
"zh:552652185bc85c8ba1da1d65dea47c454728a5c6839c458b6dcd3ce71c19ccfc",
|
"zh:3461ef14904ab7de246296e44d24c042f3190e6bead3d7ce1d9fda63dcb0f047",
|
||||||
"zh:60284b8172d09aee91eae0856f09855eaf040ce3a58d6933602ae17c53f8ed04",
|
"zh:44517a0035996431e4127f45db5a84f53ce80730eae35629eda3101709df1e5c",
|
||||||
"zh:6be38d156756ca61fb8e7c752cc5d769cd709686700ac4b230f40a6e95b5dbc9",
|
"zh:4b0374abaa6b9a9debed563380cc944873e4f30771dd1da7b9e812a49bf485e3",
|
||||||
"zh:7a409138fae4ef42e3a637e37cb9efedf96459e28a3c764fc4e855e8db9a7485",
|
"zh:531468b99465bd98a89a4ce2f1a30168dfadf6edb57f7836df8a977a2c4f9804",
|
||||||
"zh:8070cf5224ed1ed3a3e9a59f7c30ff88bf071c7567165275d477c1738a56c064",
|
"zh:6a95ed7b4852174aa748d3412bff3d45e4d7420d12659f981c3d9f4a1a59a35f",
|
||||||
"zh:894439ef340a9a79f69cd759e27ad11c7826adeca27be1b1ca82b3c9702fa300",
|
"zh:88c2d21af1e64eed4a13dbb85590c66a519f3ecc54b72875d4bb6326f3ef84e7",
|
||||||
"zh:89d035eebf08a97c89374ff06040955ddc09f275ecca609d0c9d58d149bef5cf",
|
|
||||||
"zh:985b1145d724fc1f38369099e4a5087141885740fd6c0b1dbc492171e73c2e49",
|
|
||||||
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
|
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
|
||||||
"zh:a80b47ae8d1475201c86bd94a5dcb9dd4da5e8b73102a90820b68b66b76d50fd",
|
"zh:a8b648470bb5df098e56b1ec5c6a39e0bbb7b496b23a19ea9f494bf48d4a122a",
|
||||||
"zh:d3395be1556210f82199b9166a6b2e677cee9c4b67e96e63f6c3a98325ad7ab0",
|
"zh:b23fb13efdb527677db546bc92aeb2bdf64ff3f480188841f2bfdfa7d3d907c1",
|
||||||
"zh:db0b869d09657f6f1e4110b56093c5fcdf9dbdd97c020db1e577b239c0adcbce",
|
"zh:be5858a1951ae5f5a9c388949c3e3c66a3375f684fb79b06b1d1db7a9703b18e",
|
||||||
"zh:ffc72e680370ae7c21f9bd3082c6317730df805c6797427839a6b6b7e9a26a01",
|
"zh:c368e03a7c922493daf4c7348faafc45f455225815ef218b5491c46cea5f76b7",
|
||||||
|
"zh:e31e75d5d19b8ac08aa01be7e78207966e1faa3b82ed9fe3acfdc2d806be924c",
|
||||||
|
"zh:ea84182343b5fd9252a6fae41e844eed4fdc3311473a753b09f06e49ec0e7853",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
provider "registry.terraform.io/hetznercloud/hcloud" {
|
provider "registry.terraform.io/hetznercloud/hcloud" {
|
||||||
version = "1.57.0"
|
version = "1.52.0"
|
||||||
constraints = "~> 1.45"
|
constraints = "~> 1.45"
|
||||||
hashes = [
|
hashes = [
|
||||||
"h1:xpAcuja19Ts7bCpmULKdBw4dEBJhF/eL6AjM4xDBEAI=",
|
"h1:LTjrLuC+4F1Kv4TxS9e7LVVkG8/S4QQ7X4ORblvKTbc=",
|
||||||
"zh:016ecc39328f34f6c0ffa413598f354824f7878c89cd031f123edb4bc8a687a2",
|
"zh:1e9bb6b6a2ea5f441638dbae2d60fbe04ff455f58a18c740b8b7913e2197d875",
|
||||||
"zh:10b362dc0847200c987214b129b5f85e2f7d8ad417261a1d2dd04ab74de15603",
|
"zh:29c122e404ba331cfbadacc7f1294de5a31c9dfd60bdfe3e1b402271fc8e419c",
|
||||||
"zh:194647d9a61dca4f411f44580316b88a11095d7a99679d445f9b0f2c1ba976c4",
|
"zh:2bd0ae2f0bb9f16b7753f59a08e57ac7230f9c471278d7882f81406b9426c8c7",
|
||||||
"zh:1d8aafe2ce7890696385bb3a0c3286e7ee3020416d337f59935406e4c6f91de6",
|
"zh:4383206971873f6b5d81580a9a36e0158924f5816ebb6206b0cf2430e4e6a609",
|
||||||
"zh:594585616210fb232fad4ebda2387ecd3f483931e00eff988fca83add6ce7cfc",
|
"zh:47e2ca1cfa18500e4952ab51dc357a0450d00a92da9ea03e452f1f3efe6bbf75",
|
||||||
"zh:65e50be33ffb85580546f119839e1293591cc6d4db729d809931d0408b6ae408",
|
"zh:8e9fe90e3cea29bb7892b64da737642fc22b0106402df76c228a3cbe99663278",
|
||||||
"zh:7d4ed5bd8c477ec304142e2160203a76a0d09c93d224950bda253172b2571038",
|
"zh:a2d69350a69c471ddb63bcc74e105e585319a0fc0f4d1b7f70569f6d2ece5824",
|
||||||
"zh:90a70a70a266b78c8216903e711904e6969b3957d182602b5d788602ec9ef323",
|
"zh:a97abcc254e21c294e2d6b0fc9068acfd63614b097dda365f1c56ea8b0fd5f6b",
|
||||||
"zh:abb8e28e96fb8de270995873de980896b7cb53cfc550f02c50eaa42884624ba9",
|
"zh:aba8d72d4fe2e89c922d5446d329e5c23d00b28227b4666e6486ba18ea2ec278",
|
||||||
"zh:bbf34dca2de6e105ca7204222162a0402d8e9e9a28e1de5ffbaa2c0d6270a059",
|
"zh:ad36c333978c2d9e4bc43dcadcbff42fe771a8c5ef53d028bcacec8287bf78a7",
|
||||||
"zh:c1a9edb693d632dcb5c3c9ee84c97138e08eadb9354e28592efd581f68ac0385",
|
"zh:cdb1e6903b9d2f0ad8845d4eb390fbe724ee2435fb045baeab38d4319e637682",
|
||||||
"zh:dadbf1368fae314fe8dcb99ebefbc78409f3fc0e3808cd92ea573b8eee1cae98",
|
"zh:df77b08757f3f36b8aadb33d73362320174047044414325c56a87983f48b5186",
|
||||||
"zh:e713e00ca27348abd18da2eeff861905e84050e3e7e008f14a0c63c70ab2ff84",
|
"zh:e07513d5ad387247092b5ae1c87e21a387fc51873b3f38eee616187e38b090a7",
|
||||||
|
"zh:e2be02bdc59343ff4b9e26c3b93db7680aaf3e6ed13c8c4c4b144c74c2689915",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
## Install extras.
|
|
||||||
rpm --rebuilddb
|
|
||||||
amazon-linux-extras install docker ansible2 python3.8 -y
|
|
||||||
|
|
||||||
# Make Docker work.
|
|
||||||
systemctl enable docker
|
|
||||||
systemctl start docker
|
|
||||||
|
|
||||||
# Set up the correct version of Python (for Ansible).
|
|
||||||
ln -sf /usr/bin/python3.8 /usr/bin/python3
|
|
||||||
ln -sf /usr/bin/pip3.8 /usr/bin/pip3
|
|
||||||
pip3 install botocore boto3 requests packaging --user ssm-user
|
|
||||||
python3 -m pip install -U pip
|
|
||||||
|
|
||||||
# Add some swap space.
|
|
||||||
dd if=/dev/zero of=/swapfile bs=128M count=8
|
|
||||||
chmod 600 /swapfile
|
|
||||||
mkswap /swapfile
|
|
||||||
swapon /swapfile
|
|
||||||
|
|
||||||
# Stop SSH (because we have SSM.)
|
|
||||||
service sshd stop
|
|
||||||
|
|
||||||
# Install Docker Compose.
|
|
||||||
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
||||||
chmod +x /usr/local/bin/docker-compose
|
|
||||||
|
|
||||||
# ERROR: SSM User not created yet.
|
|
||||||
sudo usermod -aG docker ssm-user
|
|
||||||
@@ -1,3 +1,17 @@
|
|||||||
|
resource "hcloud_network" "network" {
|
||||||
|
name = "network"
|
||||||
|
ip_range = "10.0.0.0/16"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "hcloud_network_subnet" "subnet" {
|
||||||
|
type = "cloud"
|
||||||
|
network_id = hcloud_network.network.id
|
||||||
|
network_zone = "eu-central"
|
||||||
|
ip_range = "10.0.10.0/24"
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
resource "hcloud_primary_ip" "public_ip" {
|
resource "hcloud_primary_ip" "public_ip" {
|
||||||
name = "repository-public-ip"
|
name = "repository-public-ip"
|
||||||
datacenter = local.datacenter
|
datacenter = local.datacenter
|
||||||
@@ -6,23 +20,31 @@ resource "hcloud_primary_ip" "public_ip" {
|
|||||||
auto_delete = false
|
auto_delete = false
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "hcloud_ssh_key" "ssh_key" {
|
resource "hcloud_ssh_key" "gitea_ssh_key" {
|
||||||
name = "repository-ssh-key"
|
name = "repository-ssh-key"
|
||||||
public_key = file(var.public_ssh_key_path)
|
public_key = file(var.public_gitea_ssh_key_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "hcloud_server" "server_instance" {
|
resource "hcloud_server" "gitea_server_instance" {
|
||||||
name = "repository-server"
|
name = "repository-gitea-server"
|
||||||
image = local.server_image
|
image = local.server_image
|
||||||
server_type = local.server_type
|
server_type = local.server_type
|
||||||
datacenter = local.datacenter
|
datacenter = local.datacenter
|
||||||
ssh_keys = [hcloud_ssh_key.ssh_key.id]
|
ssh_keys = [hcloud_ssh_key.gitea_ssh_key.id]
|
||||||
|
|
||||||
public_net {
|
public_net {
|
||||||
ipv4_enabled = true
|
ipv4_enabled = true
|
||||||
ipv4 = hcloud_primary_ip.public_ip.id
|
ipv4 = hcloud_primary_ip.public_ip.id
|
||||||
ipv6_enabled = false
|
ipv6_enabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network {
|
||||||
|
network_id = hcloud_network.network.id
|
||||||
|
ip = local.gitea_ip
|
||||||
|
alias_ips = [ ]
|
||||||
|
}
|
||||||
|
|
||||||
|
depends_on = [ hcloud_network_subnet.subnet ]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "hcloud_firewall" "server_firewall" {
|
resource "hcloud_firewall" "server_firewall" {
|
||||||
@@ -58,5 +80,34 @@ resource "hcloud_firewall" "server_firewall" {
|
|||||||
|
|
||||||
resource "hcloud_firewall_attachment" "server_fw_attachment" {
|
resource "hcloud_firewall_attachment" "server_fw_attachment" {
|
||||||
firewall_id = hcloud_firewall.server_firewall.id
|
firewall_id = hcloud_firewall.server_firewall.id
|
||||||
server_ids = [hcloud_server.server_instance.id]
|
server_ids = [hcloud_server.gitea_server_instance.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
resource "hcloud_ssh_key" "runner_ssh_key" {
|
||||||
|
name = "repository-runner-ssh-key"
|
||||||
|
public_key = file(var.public_runner_ssh_key_path)
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "hcloud_server" "runner_instance" {
|
||||||
|
name = "repository-runner-server"
|
||||||
|
image = local.server_image
|
||||||
|
server_type = local.server_type
|
||||||
|
datacenter = local.datacenter
|
||||||
|
ssh_keys = [hcloud_ssh_key.runner_ssh_key.id]
|
||||||
|
|
||||||
|
network {
|
||||||
|
network_id = hcloud_network.network.id
|
||||||
|
ip = local.runner_ip
|
||||||
|
alias_ips = [ ]
|
||||||
|
}
|
||||||
|
|
||||||
|
public_net {
|
||||||
|
ipv4_enabled = false
|
||||||
|
ipv6_enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
depends_on = [ hcloud_network_subnet.subnet ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
output "server_ip" {
|
output "server_ip" {
|
||||||
description = "The public address of the server."
|
description = "The public address of the server."
|
||||||
value = hcloud_server.server_instance.ipv4_address
|
value = hcloud_server.gitea_server_instance.ipv4_address
|
||||||
|
sensitive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
output "runner_ip" {
|
||||||
|
description = "The internal address of the CI runner."
|
||||||
|
value = local.runner_ip
|
||||||
sensitive = false
|
sensitive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
terraform/routing.tf
Normal file
13
terraform/routing.tf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# The Route53 DNS zone.
|
||||||
|
data "aws_route53_zone" "main" {
|
||||||
|
name = local.domain
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push all domain traffic through the reverse proxy.
|
||||||
|
resource "aws_route53_record" "domain" {
|
||||||
|
zone_id = data.aws_route53_zone.main.zone_id
|
||||||
|
name = "${local.subdomain}.${data.aws_route53_zone.main.name}"
|
||||||
|
type = "A"
|
||||||
|
ttl = "60"
|
||||||
|
records = [hcloud_primary_ip.public_ip.ip_address]
|
||||||
|
}
|
||||||
@@ -5,6 +5,10 @@ locals {
|
|||||||
|
|
||||||
domain = "maximhutz.com"
|
domain = "maximhutz.com"
|
||||||
subdomain = "git"
|
subdomain = "git"
|
||||||
|
|
||||||
|
network_cidr = "10.0.0.0/16"
|
||||||
|
gitea_ip = "10.0.10.16"
|
||||||
|
runner_ip = "10.0.10.17"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
@@ -15,8 +19,13 @@ variable "hcloud_token" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "public_ssh_key_path" {
|
variable "public_gitea_ssh_key_path" {
|
||||||
description = "The location of the public key used to access the repository server."
|
description = "The location of the public key used to access the repository Gitea server."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "public_runner_ssh_key_path" {
|
||||||
|
description = "The location of the public key used to access the repository Gitea Action runner."
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
variables:
|
variables:
|
||||||
image_name: mvhutz/gitea
|
image_name: mvhutz/gitea
|
||||||
|
gitea_host: repository_gitea
|
||||||
|
runner_host: repository_runner
|
||||||
149
vault.yml
149
vault.yml
@@ -1,70 +1,81 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
38643539323537353461336432353537646361303835626434666463643836353464633461383533
|
34666138303266383336633235633037626261343833333763333463373261376165393735313230
|
||||||
3639353663323362666235373161306135396663323962610a376333313966346136616461393130
|
6133336466363137653966393733373236373161663434350a356634326634346530336632653535
|
||||||
31626537333832303433393338336631623635393730353165396166623632363561613538373931
|
66386136393434616639626634376236656666656362346130343964356536393634616165303531
|
||||||
3936366135623865620a623539306562653738663634363266346335343661333766663763643761
|
6636396336303361320a353135303264313361373762303466383731313266666635316566383630
|
||||||
66393937346664653462393766363563653430353038663439383861336230623861646233373365
|
33363332623266343834633962663837383433303034336661633235616565333837623064396137
|
||||||
38613461376166633730653463656535316265353361643431303433373631356138363036336665
|
65373761343937666430336137656465643962336561346630626638343064306330323636366234
|
||||||
62363066313531313064313633353837623338313761636431383832643433646562323531383336
|
38363035323061663266663466336638366236346162373338396538333637613834353235613061
|
||||||
33343837366635653632316539376162633834363964613138376636666465376234303332643336
|
38313339353262643232613832623963376638643439666333333031356162303834363933313833
|
||||||
36373539656532323264313431323364656438363562363962393135383733656562666635616265
|
35336332316337353936313963343636636464656639313930613133333866303933336635663737
|
||||||
66323637306662663464386235646335363432616437336332656162656337326535336335343432
|
65663237663865313566666133666161626539376463363439313365333366323561653666616533
|
||||||
39356338303430383034383030323737636265353534356130363837373236343262663361313737
|
61383334383230663330326236366262323464633432613562313239613031666261626334323666
|
||||||
37613839613432376532643962663538633231633837343962373233363830646332623237633930
|
61616534343436356631383764383139386630656165376461313432643136653463306435353261
|
||||||
37373066613436636639326334363364323834323931653738653837326363323230643161663762
|
65313363383339353434663139303961393865353230646138633161626235636437636135653763
|
||||||
65353366396666373666383530363861623833393764313865306465303631383664663730643066
|
30313736366263303866313466333464303666396334643531343734623562636439616239663737
|
||||||
66393736323763323538346131663263306566303334366234633864653561393434393562633539
|
32653536646234343435376365623466346131353262663261653438666137386662326332343263
|
||||||
32303034303566616632313737303333326365326564313132376364353466376635646131613065
|
38343966373931326232393838613763653731383038373338353863303264366162373966613563
|
||||||
30646563643239306133313163643032363830653338346335363333316232633164376335373639
|
36363137636236643663373837383161386266313963363437663835663037316230373466643466
|
||||||
33633837313736633735343835353663323165386238636262373937613731323833323634646531
|
61353931653031313133393163353639373736636139366430653865663335303230306662393632
|
||||||
30366134643162623666323331636235333635386262323231626261353938623662323936393731
|
30666435633434656434313736323732383135383638383334393433333530646661396232383635
|
||||||
32383735646631316431633035323933336134356363663732633230636535373238633632636566
|
35363430313837373136643230386666623436383239336339623565356630303766333832306261
|
||||||
38373136323862366333303737376337366438373231343339383163333661613530366362313738
|
63396565623164633466356437316233386561313932626262613162326332306638363130613533
|
||||||
38633736373530613032323431366239633236656432633936663939306265316638643163383064
|
62363665363032646565643036636233323966373362663163373165323934383263316232323965
|
||||||
63326666663865663966333730356435356234343562393630343466393164393466303561316536
|
39663733346637663735613434326239633337613933633765306261616363396465623565346136
|
||||||
63663630393234623961366639323030313739616235653830356364663731366537343866333831
|
35336333363461653163343436633963343830306264333665393338363039636139343934353361
|
||||||
33336639653535316632613236343033393930623464343838653436643234343332623539306331
|
39613664383134663766623165386266623661356230396535346166653761633831663566366339
|
||||||
65663663373333303931326330663664663330353539376530303838643264356164633135626335
|
65353933663861333539336130633262303038633639333137313232363535636531353435303635
|
||||||
61613739336237666330373138373132346631666366666235346662363839383263323939383138
|
39306433633261303634616533666230396566616131363435383662363432613634386266373966
|
||||||
39656137343362636432343737616565646163623130623939616336616332616533303261656665
|
38323933303164323565326534326364646562316539643132616364646137323735373236633637
|
||||||
36306364643064643364666237663630376165303232313763383464313462353831306562666535
|
36646337356333643766393464626633643263313437343932306634363532626563646163353661
|
||||||
39363930396439633432373330636637313636316365306532333265626433333563343333323064
|
65636461663736663136366462346462633065313763666532303532366538386239383465323966
|
||||||
36393161383135346535623833396466323332323537316431646134343165353966613331313563
|
36333465313338613635373336306266643862623262306237666235633532373163356630303163
|
||||||
63326538643038346634323664393565656263323765363334353631616362343835666133383538
|
32353563623162303465376237313264646132656565313335653964323233636562613664316538
|
||||||
35626334363366323832636366346166373638666132623931633963663336363230316431356666
|
32383737316362356365613064393662316434303932643136313866326235636632353135373735
|
||||||
31636135303532313537666261393238396666326264323566646230663434323931323030343433
|
38656536623134623263656338356436656137313563353366666366643535393662356433376237
|
||||||
30356438323032353164333762653630656430306562313036353631663033646666363165623431
|
30343961653363376162626333323261316635333366366131343136383362386131396466383662
|
||||||
65613736393163363564326362303766363833623665343563326437383436336261346634343535
|
32393361383534636662663439363630663064383834363036396463383362666637646436326462
|
||||||
65343062373731623439623033323939343137326531316562383962363161666166646138393333
|
36653734353036613139653462363563613635643166333262623533316330666166613239613136
|
||||||
39353564303738396538613663633430653532643234656366653934333637376635363933313237
|
30366662333666653038303035323163323438323535366339646539323063373761346337373163
|
||||||
64303762303138613335393938306137346336393966666532313963653635643738306436316230
|
63393833373663356635646236616564353936366437633766616333656538366263353664363031
|
||||||
64623165656265393938326335656636386437643432383430376138393964643164646638633065
|
65303462623737323638326661326134303635353065323666616331323933646531376239626630
|
||||||
66396635343435353633636637613933306536306161633238386162633361313639303933653436
|
35383232316666643166646232383837646262306331663337663961653861613536616632663764
|
||||||
66303365366463353439386336313134316265306663646531376266306662366466653132323233
|
39326331373633336661346133316434623434306636643839306136363734353330663237366564
|
||||||
37623061663132633539313963396434353734643339393164353066653838346337306464643437
|
32353237306633626564633034383466306239323833343838316638663065323834666438666135
|
||||||
64623631393235636137666464653431323661326163626639396635666434633939653566343030
|
36643832646434633262393634333264333964383433643866356232613536396339353536346538
|
||||||
32643364316131336537613237373561653766383834353765633639343964383134313265303632
|
62383832393033336133346435303463626165643463326538353864343565373830636635663237
|
||||||
35656534666662663732353238333830326531393262633039356332386439653963346661346535
|
38653239393061353334326662633735643238333231663437343238613730383937363834623664
|
||||||
35376432663663336430653861323266373033383634626337366334363133303430616663353931
|
37363661636230636632383331613264383064366238396163373838343062646432653462616635
|
||||||
31643134653161646665646561643764336635623333653933643231663863653032666330383537
|
38313835333437653734336162326662346466633533623565376262653134373730356337623165
|
||||||
65333534323331396262633163343662663966653336616330323365666133653139623761316333
|
62376464623438343165323037653631326565613737313062666232663130643638643165343466
|
||||||
39616566386365383134393836373134633763373936616365363238323934623734313161396135
|
30636261343730366233643634643963363061346361663732663336393239623934313561626461
|
||||||
39656135383731623661646361373531643630643137343934393539656334373335636132353130
|
33636365383863343138343964303630643463633732623462636465323464353063353134636430
|
||||||
31323333336264366435636435653961366165386431313532656631666138336431333366623664
|
37653764396236386233313766393339323735623139633966336237363061326431636566376137
|
||||||
35316566666366393665333131313434353266356366373930373339636530613530653738633738
|
30366636663235613136303462363035623135636461343638323266663661616335326332353034
|
||||||
33646531363634343761343438396338656264326163616162306431366432616434316231366465
|
62333130373830613363396331613336616531313064356165613930373230383234363561346632
|
||||||
63623962383465626437363664653431396630343231356134353331666461613865326164653532
|
64346635646338356430313536353436626265383561643166346561356430663238636561653363
|
||||||
62653535343830346363636534366366373337653764353431623565626663376461666438653839
|
62386365363466663931333663373737646563363639356161613464373534643965653236356639
|
||||||
32633031333833613532613465623764386661616363643033613261613632653636643066303162
|
63636237666332643966353131656435613933663230363665376333346563616634316430373235
|
||||||
39393133646633613464393161313464663233396133633264346431626538663037663732386136
|
33643738326164656664643730376266666236333631393634356133633432373031613030663464
|
||||||
39653863303030343639353836373731303239666262363432373565326365346566643137653730
|
61613964346133663638623038323161316665653436306533633438383563333465643731373537
|
||||||
39623663353161626564383166383432656538383935343331646339636333366364646330373435
|
64333531653437373531306631363533643736326462343138323739356463383465626638626164
|
||||||
62666432336330636135393231356339366639626234656633656531353031623434663034383164
|
62653862643032356264396461363530346633336230326166323563323830646464656633356430
|
||||||
64316131316432373533363764393934323061393034663761363562313865666635303733613862
|
33323163626633303639613138343765626633323563303236396164376336396362306265363365
|
||||||
35633363386663316636326333393634353564393935643562663962303564383530343762323466
|
38663237323533336263323636643536343963346337313938343262323366666130383339323337
|
||||||
64376164383337633436616563303761373533383132346131313465653336366463346166343534
|
31396361316438333262656231356566363635343465383265633133343338376363303962343131
|
||||||
36316266613037353361306637353065313761656463373632633737663263333265336532323461
|
34363537643731633735663635653163386264383334366134626230396439666439313963373934
|
||||||
38343566636131663736393266303063333835373438313162383634323239666638303061636639
|
38373237383239336333656235613963623766343565653865623861353735366638356137313161
|
||||||
37313430383161316365363136353331393764613830653264373835633532303066666166326138
|
63643735656463633063386239383961663230326665616233343634366531623561613732393131
|
||||||
33373330633737383139613337393739626535626435383364393865393838393636663135653634
|
34623665333866343962306234623538306234653264373534633062363263653638303736666537
|
||||||
6334
|
32383832343939353438663738636537333834383934666536303233313763616434373663313737
|
||||||
|
65313465313161656565376532386564646435373062313964633033616564393632623338666261
|
||||||
|
62363034643363303337353565326438313832636165316363393238353531383837616337366530
|
||||||
|
36663733376436336639633431313263373337313239303563313962663361653633356637616239
|
||||||
|
64616665623563656137313537346238393432636235326164303165303136356264646634623438
|
||||||
|
61633334303539616366653763383134643764323735333163353036373961353738386630643030
|
||||||
|
61333861316565363536386465316637613065356235633335363834613733386130343132363130
|
||||||
|
33663866656163386265303163613164303538333462343233343930346261663430383038343833
|
||||||
|
34666439633562356633633666653338396131383531666238383962613737376531376638643265
|
||||||
|
34313464313136356532313439616365386133653334383266383564333562663366386631656663
|
||||||
|
37643837336138336237336462393937333437623665323063383464353662653865343433613164
|
||||||
|
36346433653537656264
|
||||||
|
|||||||
Reference in New Issue
Block a user