| 1 | ---
|
| 2 | # roles/app/tasks/main.yml
|
| 3 | # Places the production app config in /srv/app/<env>/
|
| 4 | # The env files are rendered from group_vars (secrets come from the encrypted
|
| 5 | # vault.yml), so there is nothing to fill in by hand anymore
|
| 6 |
|
| 7 | - name: Ensure /srv/app exists
|
| 8 | ansible.builtin.file:
|
| 9 | path: /srv/app
|
| 10 | state: directory
|
| 11 | owner: "{{ deploy_user }}"
|
| 12 | group: "{{ deploy_user }}"
|
| 13 | mode: "0750"
|
| 14 | tags: [app]
|
| 15 |
|
| 16 | - name: Ensure the per-environment app directories exist
|
| 17 | ansible.builtin.file:
|
| 18 | path: "/srv/app/{{ item }}"
|
| 19 | state: directory
|
| 20 | owner: "{{ deploy_user }}"
|
| 21 | group: "{{ deploy_user }}"
|
| 22 | mode: "0750"
|
| 23 | loop: "{{ app_environments }}"
|
| 24 | tags: [app]
|
| 25 |
|
| 26 | - name: Install the production compose file
|
| 27 | ansible.builtin.copy:
|
| 28 | src: docker-compose.production.yml
|
| 29 | dest: "/srv/app/{{ app_env }}/docker-compose.yml"
|
| 30 | owner: "{{ deploy_user }}"
|
| 31 | group: "{{ deploy_user }}"
|
| 32 | mode: "0640"
|
| 33 | tags: [app]
|
| 34 |
|
| 35 | - name: Install the valkey configuration
|
| 36 | ansible.builtin.copy:
|
| 37 | src: valkey.conf
|
| 38 | dest: "/srv/app/{{ app_env }}/valkey.conf"
|
| 39 | owner: "{{ deploy_user }}"
|
| 40 | group: "{{ deploy_user }}"
|
| 41 | mode: "0640"
|
| 42 | tags: [app]
|
| 43 |
|
| 44 | - name: Install the Vector configuration
|
| 45 | ansible.builtin.copy:
|
| 46 | src: vector.yaml
|
| 47 | dest: "/srv/app/{{ app_env }}/vector.yaml"
|
| 48 | owner: "{{ deploy_user }}"
|
| 49 | group: "{{ deploy_user }}"
|
| 50 | mode: "0640"
|
| 51 | tags: [app]
|
| 52 |
|
| 53 | - name: Install the environment files
|
| 54 | ansible.builtin.template:
|
| 55 | src: "{{ item.src }}"
|
| 56 | dest: "/srv/app/{{ app_env }}/{{ item.dest }}"
|
| 57 | owner: "{{ deploy_user }}"
|
| 58 | group: "{{ deploy_user }}"
|
| 59 | mode: "0600"
|
| 60 | loop:
|
| 61 | - { src: env.j2, dest: .env }
|
| 62 | - { src: env.production.j2, dest: .env.production }
|
| 63 | loop_control:
|
| 64 | label: "{{ item.dest }}"
|
| 65 | tags: [app]
|