Skip to content

Commit

Permalink
feat: add cleanup step
Browse files Browse the repository at this point in the history
  • Loading branch information
janikvonrotz committed Jan 17, 2025
1 parent 3d6c34c commit ecbfdcb
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Run task install
run: ./task install
- name: Run task test
Expand Down
14 changes: 3 additions & 11 deletions localhost/host_vars/localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ hosts:
- ip: 10.101.16.2
name: erp.brunner-innovation.swiss erp-dev.brunner-innovation.swiss gaia.mint-system.com

# https://registry.hub.docker.com/_/rabbitmq/
rabbitmq_image: rabbitmq:3.8-management
rabbitmq_hostname: mq01
rabbitmq_data_dir: "/usr/share/{{ odoo_hostname }}"
rabbitmq_ports:
- 127.0.0.1:5672:5672
- 127.0.0.1:8080:15672
rabbitmq_user: admin
rabbitmq_password: admin

# https://hub.docker.com/_/postgres
postgres_image: postgres:14
# postgres_build_image: true # default: false
Expand Down Expand Up @@ -70,6 +60,8 @@ nginx_http_options: |
default upgrade;
'' close;
}
nginx_ports:
- 8080:80
nginx_proxies:
- src_hostname: metabase.local
dest_hostname: metabase01-prod
Expand Down Expand Up @@ -115,5 +107,5 @@ odoo_postgres_hostname: "{{ postgres_hostname }}"
metabase_image: metabase/metabase:v0.51.12.1
metabase_hostname: metabase01
metabase_db_host: postgres01
metabase_db_user: test
metabase_db_user: example
metabase_db_pass: test
1 change: 1 addition & 0 deletions roles/clean/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ odoo_config_map:
- name: prod
odoo_volume_name: "{{ odoo_hostname }}"
postgres_volume_name: "{{ postgres_hostname }}"
nginx_data_dir: "/usr/share/{{ nginx_hostname }}"
1 change: 1 addition & 0 deletions roles/clean/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
- pgadmin
- meilisearch
- crowdsec
- metabase
6 changes: 6 additions & 0 deletions roles/clean/tasks/metabase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Remove metabase container {{ metabase_hostname }}
community.docker.docker_container:
name: "{{ metabase_hostname }}-{{ item.name}}"
state: absent
loop: "{{ metabase_config_map }}"
17 changes: 5 additions & 12 deletions task
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,12 @@ function galaxy-publish() {

function test() {
activate-venv
ansible-playbook -i localhost plays/localhost.yml

if [ "$1" = "clean" ]; then
echo "Cleanup server"
ansible-playbook -i localhost plays/clean.yml -i odoo,odoo_data,odoo_volume,\
postgres,postgres_data,postgres_volume,\
rabbitmq,rabbitmq_data,rabbitmq_volume,\
meilisearch,meilisearch_data,meilisearch_volume,\
pgadmin,pgadmin_data,pgadmin_volume,\
n8n,n8n_data,n8n_volume,\
nginx,nginx_data,nginx_volume,\
crowdsec,crowdsec_data,crowdsec_volume,\
metabase,metabase_data,metabase_volume
echo "Cleanup localhost"
ansible-playbook -i localhost plays/clean.yml -t odoo,odoo_data,odoo_volume,postgres,postgres_data,postgres_volume,meilisearch,meilisearch_data,meilisearch_volume,pgadmin,pgadmin_data,pgadmin_volume,n8n,n8n_data,n8n_volume,nginx,nginx_data,nginx_volume,metabase,metabase_data,metabase_volume
else
echo "Setup localhost"
ansible-playbook -i localhost plays/localhost.yml --skip-tags check
fi
}

Expand Down

0 comments on commit ecbfdcb

Please sign in to comment.