All checks were successful
CI / skip-ci-check (pull_request) Successful in 1m22s
CI / lint-and-test (pull_request) Successful in 1m27s
CI / ansible-validation (pull_request) Successful in 2m53s
CI / secret-scanning (pull_request) Successful in 1m24s
CI / dependency-scan (pull_request) Successful in 1m28s
CI / sast-scan (pull_request) Successful in 2m32s
CI / license-check (pull_request) Successful in 1m28s
CI / vault-check (pull_request) Successful in 2m30s
CI / playbook-test (pull_request) Successful in 2m32s
CI / container-scan (pull_request) Successful in 1m53s
CI / sonar-analysis (pull_request) Successful in 2m40s
CI / workflow-summary (pull_request) Successful in 1m22s
- Fix deploy script to handle non-git directories by cloning to temp location and moving contents, preserving .env files during clone - Remove comment lines from env.j2 template to prevent xargs errors - Add initial deploy task to app_setup role to ensure app is deployed before service starts - Fix migrate command precedence to check env-specific overrides first - Add sudo to systemctl restart commands in deploy script - Update documentation with project-specific configuration notes These changes improve deployment reliability for all app projects while adding support for mirrormatch-specific requirements (db:push, seeding). All changes are backward-compatible with existing projects (pote, punimTag).
75 lines
1.9 KiB
YAML
75 lines
1.9 KiB
YAML
---
|
|
# Role: app_setup
|
|
# Purpose: create app layout, env file, deploy script, and systemd units.
|
|
|
|
- name: Ensure app root directory exists
|
|
ansible.builtin.file:
|
|
path: "{{ app_root }}"
|
|
state: directory
|
|
owner: "{{ app_owner }}"
|
|
group: "{{ app_group }}"
|
|
mode: "0755"
|
|
|
|
- name: Deploy environment file for this env
|
|
ansible.builtin.template:
|
|
src: env.j2
|
|
dest: "{{ app_root }}/.env.{{ app_env }}"
|
|
owner: "{{ app_owner }}"
|
|
group: "{{ app_group }}"
|
|
mode: "0640"
|
|
|
|
- name: Deploy deploy script
|
|
ansible.builtin.template:
|
|
src: deploy_app.sh.j2
|
|
dest: /usr/local/bin/deploy_app.sh
|
|
owner: root
|
|
group: root
|
|
mode: "0755"
|
|
|
|
- name: Run initial deploy (clone, install, build, migrate, seed)
|
|
ansible.builtin.command:
|
|
cmd: /usr/local/bin/deploy_app.sh
|
|
become: true
|
|
become_user: "{{ app_owner }}"
|
|
args:
|
|
chdir: "{{ app_root }}"
|
|
register: deploy_result
|
|
changed_when: true
|
|
|
|
- name: Deploy systemd unit for backend
|
|
ansible.builtin.template:
|
|
src: app-backend.service.j2
|
|
dest: /etc/systemd/system/app-backend.service
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
notify: Reload systemd
|
|
when: app_enable_backend | bool
|
|
|
|
- name: Deploy systemd unit for frontend
|
|
ansible.builtin.template:
|
|
src: app-frontend.service.j2
|
|
dest: /etc/systemd/system/app-frontend.service
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
notify: Reload systemd
|
|
when: app_enable_frontend | bool
|
|
|
|
- name: Ensure systemd is reloaded before enabling services
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: Enable and start backend service
|
|
ansible.builtin.systemd:
|
|
name: app-backend.service
|
|
enabled: true
|
|
state: started
|
|
when: app_enable_backend | bool
|
|
|
|
- name: Enable and start frontend service
|
|
ansible.builtin.systemd:
|
|
name: app-frontend.service
|
|
enabled: true
|
|
state: started
|
|
when: app_enable_frontend | bool
|