55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
- name: Dossier pour le service docker
|
|
ansible.builtin.file:
|
|
path: /opt/{{ docker_mastodon_service_id }}/
|
|
state: directory
|
|
|
|
- name: Prepare docker-compose.yml
|
|
ansible.builtin.template:
|
|
src: "{{ item }}"
|
|
dest: /opt/{{ docker_mastodon_service_id }}/
|
|
with_items:
|
|
- docker-compose.yml
|
|
- .env.production
|
|
|
|
- name: Generation des secrets
|
|
when: docker_mastodon_gen_secrets is true
|
|
block:
|
|
|
|
- name: Script pour la génération des secrets
|
|
ansible.builtin.shell: |
|
|
docker compose down
|
|
echo "Placer les valeurs suivantes dans les variables du playbook mastodon :"
|
|
echo SECRET_KEY_BASE=$(docker compose run --rm web bundle exec rake secret)
|
|
echo OTP_SECRET=$(docker compose run --rm web bundle exec rake secret)
|
|
docker compose run --rm web bundle exec rake mastodon:webpush:generate_vapid_key
|
|
docker compose run --rm web bin/rails db:encryption:init
|
|
docker compose down
|
|
args:
|
|
chdir: /opt/{{ docker_mastodon_service_id }}/
|
|
register: secrets
|
|
|
|
- name: Affiche les secrets
|
|
ansible.builtin.debug:
|
|
msg: "{{ secrets.stdout_lines }}"
|
|
|
|
- name: On s'arrête ici si docker_mastodon_gen_secrets est défini
|
|
ansible.builtin.assert:
|
|
that:
|
|
- docker_mastodon_gen_secrets is false
|
|
|
|
### initialize-data
|
|
- name: Migration BDD et précompilation
|
|
ansible.builtin.shell: |
|
|
docker compose down
|
|
docker compose run --rm web rails db:migrate
|
|
docker compose run --rm web rails assets:precompile
|
|
docker compose down
|
|
args:
|
|
chdir: /opt/{{ docker_mastodon_service_id }}/
|
|
when: docker_mastodon_initialize_data is true
|
|
|
|
- name: Démarrage
|
|
ansible.builtin.shell: |
|
|
docker compose up -d
|
|
args:
|
|
chdir: /opt/{{ docker_mastodon_service_id }}/
|