|
| 1 | +# SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]> |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +--- |
| 6 | +- name: Main site for codingteam.org.ru |
| 7 | + hosts: xmpp2 |
| 8 | + become: true |
| 9 | + |
| 10 | + vars: |
| 11 | + # Container versions: |
| 12 | + postgresql_version: 9.3 |
| 13 | + loglist_version: 2.0.1 |
| 14 | + |
| 15 | + # Paths on host: |
| 16 | + host_db_init_scripts_dir: /opt/codingteam/loglist/init_db_scripts |
| 17 | + host_data_dir: /opt/codingteam/loglist/data |
| 18 | + host_config_dir: /opt/codingteam/loglist/config |
| 19 | + |
| 20 | + # Paths in containers: |
| 21 | + container_data_dir: /data |
| 22 | + |
| 23 | + vars_files: |
| 24 | + - secrets.yml |
| 25 | + |
| 26 | + handlers: |
| 27 | + - name: Prune Docker |
| 28 | + community.docker.docker_prune: |
| 29 | + containers: true |
| 30 | + images: true |
| 31 | + images_filters: |
| 32 | + dangling: false |
| 33 | + networks: true |
| 34 | + volumes: true |
| 35 | + builder_cache: true |
| 36 | + |
| 37 | + tasks: |
| 38 | + - name: Create directories |
| 39 | + ansible.builtin.file: |
| 40 | + path: '{{ item }}' |
| 41 | + state: directory |
| 42 | + mode: 'u=rwx,g,o=rx' |
| 43 | + loop: |
| 44 | + - '{{ host_db_init_scripts_dir }}' |
| 45 | + - '{{ host_data_dir }}' |
| 46 | + - '{{ host_config_dir }}' |
| 47 | + |
| 48 | + - name: Create the Docker network |
| 49 | + community.docker.docker_network: |
| 50 | + name: loglist |
| 51 | + |
| 52 | + - name: Copy the database initialization script |
| 53 | + ansible.builtin.copy: |
| 54 | + src: loglist/init_db.sql |
| 55 | + dest: '{{ host_db_init_scripts_dir }}/init_db.sql' |
| 56 | + mode: 'u,g,o=rx' |
| 57 | + |
| 58 | + - name: Set up the database container |
| 59 | + community.docker.docker_container: |
| 60 | + name: loglist.postgresql |
| 61 | + image_name_mismatch: recreate |
| 62 | + image: postgres:{{ postgresql_version }} |
| 63 | + published_ports: |
| 64 | + - '5423' |
| 65 | + env: |
| 66 | + POSTGRES_DB: loglist |
| 67 | + POSTGRES_USER: loglist |
| 68 | + POSTGRES_PASSWORD: '{{ loglist_secrets.db_password }}' |
| 69 | + PGDATA: '{{ container_data_dir }}' |
| 70 | + volumes: |
| 71 | + - '{{ host_db_init_scripts_dir }}/:/docker-entrypoint-initdb.d/' |
| 72 | + - '{{ host_data_dir }}/:/{{ container_data_dir }}/' |
| 73 | + networks: |
| 74 | + - name: loglist |
| 75 | + default_host_ip: '' |
| 76 | + notify: Prune Docker |
| 77 | + |
| 78 | + - name: Copy the application configuration file |
| 79 | + ansible.builtin.copy: |
| 80 | + src: loglist/app.conf |
| 81 | + dest: '{{ host_config_dir }}/app.conf' |
| 82 | + mode: 'u,g,o=rx' |
| 83 | + |
| 84 | + - name: Set up the application container |
| 85 | + community.docker.docker_container: |
| 86 | + name: loglist.app |
| 87 | + image_name_mismatch: recreate |
| 88 | + image: codingteam/loglist:{{ loglist_version }} |
| 89 | + published_ports: |
| 90 | + - '9000:9000' |
| 91 | + env: |
| 92 | + APPLY_EVOLUTIONS_SILENTLY: 'true' |
| 93 | + APPROVAL_EMAIL: '{{ loglist_secrets.approval_email.name }}' |
| 94 | + APPROVAL_EMAIL_PASSWORD: '{{ loglist_secrets.approval_email.password }}' |
| 95 | + APPROVAL_SMTP_HOST: '{{ loglist_secrets.approval_email.smtp_host }}' |
| 96 | + BASIC_AUTH_PASSWORD: '{{ loglist_secrets.basic_auth.password }}' |
| 97 | + BASIC_AUTH_USERNAME: '{{ loglist_secrets.basic_auth.username }}' |
| 98 | + DATABASE_URL: 'jdbc:postgresql://loglist.postgresql/loglist?user=loglist&password={{ loglist_secrets.db_password }}' |
| 99 | + JAVA_OPTS: '-Xmx200m -Xss512k -XX:+UseCompressedOops' |
| 100 | + RECAPTCHA_PRIVATE_KEY: '{{ loglist_secrets.recaptcha.private_key }}' |
| 101 | + RECAPTCHA_PUBLIC_KEY: '{{ loglist_secrets.recaptcha.public_key }}' |
| 102 | + HTTP_SECRET_KEY: '{{ loglist_secrets.http_secret_key }}' |
| 103 | + volumes: |
| 104 | + - '{{ host_db_init_scripts_dir }}/:/docker-entrypoint-initdb.d/' |
| 105 | + - '{{ host_data_dir }}/:/{{ container_data_dir }}/' |
| 106 | + networks: |
| 107 | + - name: loglist |
| 108 | + default_host_ip: '' |
| 109 | + notify: Prune Docker |
0 commit comments