diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0047684 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# ---> Ansible +*.retry + +# ---> Terraform +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Ignore transient lock info files created by terraform apply +.terraform.tfstate.lock.info + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + diff --git a/opdracht-2/gitea-runner.yml b/opdracht-2/gitea-runner.yml index d66fa95..68ce37b 100644 --- a/opdracht-2/gitea-runner.yml +++ b/opdracht-2/gitea-runner.yml @@ -14,3 +14,4 @@ - geerlingguy.pip - geerlingguy.docker - gitea-runner + - terraform-state-backend diff --git a/opdracht-2/roles/terraform-state-backend/defaults/main.yml b/opdracht-2/roles/terraform-state-backend/defaults/main.yml new file mode 100644 index 0000000..7518d92 --- /dev/null +++ b/opdracht-2/roles/terraform-state-backend/defaults/main.yml @@ -0,0 +1,5 @@ +terraform_state_image: "postgres:14" +terraform_state_container_name: "terraform_state_backend" +terraform_state_user: "terraform" +terraform_state_password: "tfbackend123" +terraform_state_db: "terraform_state" diff --git a/opdracht-2/roles/terraform-state-backend/tasks/main.yml b/opdracht-2/roles/terraform-state-backend/tasks/main.yml new file mode 100644 index 0000000..88f0ec6 --- /dev/null +++ b/opdracht-2/roles/terraform-state-backend/tasks/main.yml @@ -0,0 +1,18 @@ +- name: Delete existing backend-container + community.docker.docker_container: + name: "{{ terraform_state_container_name }}" + state: absent + +- name: Gitea Runner container starten + community.docker.docker_container: + name: "{{ terraform_state_container_name }}" + image: "{{ terraform_state_image }}" + restart_policy: always + ports: + - 5432:5432 + env: + POSTGRES_USER: "{{ terraform_state_user }}" + POSTGRES_PASSWORD: "{{ terraform_state_password }}" + POSTGRES_DB: "{{ terraform_state_db }}" + volumes: + - terraform_state_data:/var/lib/postgresql/data