From 4b90ca526286ec74a013850e6b268730fe986997 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Sat, 22 Oct 2022 22:56:35 -0400 Subject: [PATCH] testing --- dev/proxy.yml | 1 + roles/.gitignore | 3 ++ roles/kutt/defaults/main.yml | 15 +++++++++ roles/kutt/tasks/main.yml | 22 +++++++++++++ roles/kutt/templates/compose-env.j2 | 11 +++++++ roles/kutt/templates/docker-compose.yml.j2 | 36 ++++++++++++++++++++++ 6 files changed, 88 insertions(+) create mode 100644 roles/kutt/defaults/main.yml create mode 100644 roles/kutt/tasks/main.yml create mode 100644 roles/kutt/templates/compose-env.j2 create mode 100644 roles/kutt/templates/docker-compose.yml.j2 diff --git a/dev/proxy.yml b/dev/proxy.yml index b01bc74..0e593ef 100644 --- a/dev/proxy.yml +++ b/dev/proxy.yml @@ -10,3 +10,4 @@ - docker - gitea - bitwarden + - kutt diff --git a/roles/.gitignore b/roles/.gitignore index bb43362..23ca6d6 100644 --- a/roles/.gitignore +++ b/roles/.gitignore @@ -1,11 +1,14 @@ +# Sort roles: tail -n +6 roles/.gitignore | sort /* !.gitignore !requirements.yml +# roles !base*/ !bitwarden*/ !docker*/ !gitea*/ !jenkins*/ +!kutt*/ !libvirt*/ !mariadb*/ !minecraft*/ diff --git a/roles/kutt/defaults/main.yml b/roles/kutt/defaults/main.yml new file mode 100644 index 0000000..90fc7dc --- /dev/null +++ b/roles/kutt/defaults/main.yml @@ -0,0 +1,15 @@ +# container settings +kutt_name: kutt +kutt_webport: 3030 +kutt_web: "127.0.0.1:{{ kutt_webport }}" + +# database settings +kutt_dbname: "{{ kutt_name }}" +kutt_dbuser: "{{ kutt_name }}" +kutt_postgres_volume: postgres_data + +# redis +kutt_redis_volume: redis_data + +# host +kutt_root: "{{ docker_compose_root }}/{{ kutt_name }}" diff --git a/roles/kutt/tasks/main.yml b/roles/kutt/tasks/main.yml new file mode 100644 index 0000000..68d3776 --- /dev/null +++ b/roles/kutt/tasks/main.yml @@ -0,0 +1,22 @@ +- name: Create Kutt directory + file: + path: "{{ kutt_root }}" + state: directory + +- name: Install Kutt's docker-compose file + template: + src: docker-compose.yml.j2 + dest: "{{ kutt_root }}/docker-compose.yml" + notify: restart_kutt + +- name: Install Kutt's docker-compose variables + template: + src: compose-env.j2 + dest: "{{ kutt_root }}/.env" + notify: restart_kutt + +- name: Start and enable Gitea service + service: + name: "{{ docker_compose_service }}@{{ kutt_name }}" + state: started + enabled: true diff --git a/roles/kutt/templates/compose-env.j2 b/roles/kutt/templates/compose-env.j2 new file mode 100644 index 0000000..8a05c25 --- /dev/null +++ b/roles/kutt/templates/compose-env.j2 @@ -0,0 +1,11 @@ +# {{ ansible_managed }} + +kutt_version={{ kutt_version }} +kutt_name={{ kutt_name }} +kutt_web={{ kutt_web }} +kutt_dbname={{ kutt_dbname }} +kutt_dbuser={{ kutt_dbuser }} +kutt_dbpass={{ kutt_dbpass }} +kutt_redis_version={{ kutt_redis_version }} +kutt_postgres_version={{ kutt_postgres_version }} +kutt_postgres_volume={{ kutt_postgres_volume }} diff --git a/roles/kutt/templates/docker-compose.yml.j2 b/roles/kutt/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..f77674c --- /dev/null +++ b/roles/kutt/templates/docker-compose.yml.j2 @@ -0,0 +1,36 @@ +version: "3.7" + +services: + kutt: + image: kutt/kutt:${kutt_version} + container_name: ${kutt_name} + depends_on: + - postgres + - redis + command: ["./wait-for-it.sh", "postgres:5432", "--", "npm", "start"] + ports: + - ${kutt_web}:3000 + environment: + DB_HOST: postgres + DB_NAME: ${kutt_dbname} + DB_USER: ${kutt_dbuser} + DB_PASSWORD: ${kutt_dbpass} + REDIS_HOST: redis + + redis: + image: redis:${kutt_redis_version} + volumes: + - {{ kutt_redis_volume }}:/data + + postgres: + image: postgres:${kutt_postgres_version} + environment: + POSTGRES_USER: ${kutt_dbuser} + POSTGRES_PASSWORD: ${kutt_dbpass} + POSTGRES_DB: ${kutt_dbname} + volumes: + - {{ kutt_postgres_volume }}:/var/lib/postgresql/data + +volumes: + {{ kutt_redis_volume }}: + {{ kutt_postgres_volume }}: