---
- name: "π Decidim | Resolve hosting node + container ID ({{ DEPLOYMENT_MODE }})"
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
vars:
resolve_service_key: decidim
resolve_output_prefix: DECIDIM
resolve_compose_cid: "{{ DECIDIM_CONTAINER }}"
- name: "β³ Decidim | Wait for web container to be healthy"
ansible.builtin.shell: >
container inspect --type container --format '{{ "{{.State.Health.Status}}" }}'
{{ DECIDIM_LOCAL_CID | quote }}
register: decidim_health
changed_when: false
retries: 60
delay: 15
until: (decidim_health.stdout | trim) == 'healthy'
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "βΆοΈ Decidim | Run database migrations"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
container exec -e RAILS_ENV={{ ENVIRONMENT | quote }}
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails db:migrate
register: decidim_migrate_result
changed_when: decidim_migrate_result.stdout_lines | default([]) | length > 0
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "ποΈ Decidim | Create the organization"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
container exec -i -e RAILS_ENV={{ ENVIRONMENT | quote }}
-e DECIDIM_ORG_HOST={{ domain | quote }}
-e DECIDIM_ORG_NAME={{ DECIDIM_ORGANIZATION_NAME | quote }}
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails runner -
args:
stdin: "{{ lookup('file', 'ruby/ensure/organization.rb') }}"
register: decidim_organization_result
changed_when: "'Organization created' in decidim_organization_result.stdout"
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "π± Decidim | Seed the demo data"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
container exec -e RAILS_ENV={{ ENVIRONMENT | quote }}
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails db:seed
register: decidim_demo_seed
changed_when: true
when: MODE_DEMO | bool
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "π Decidim | Ensure default static pages exist (terms-of-service)"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
container exec -i -e RAILS_ENV={{ ENVIRONMENT | quote }}
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails runner -
args:
stdin: "{{ lookup('file', 'ruby/ensure/default_pages.rb') }}"
register: decidim_pages_result
changed_when: "'Default pages ensured' in decidim_pages_result.stdout"
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "π§ Decidim | Set organization host"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
container exec -i -e RAILS_ENV={{ ENVIRONMENT | quote }}
-e DECIDIM_ORG_HOST={{ domain | quote }}
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails runner -
args:
stdin: "{{ lookup('file', 'ruby/set_organization_host.rb') }}"
register: decidim_org_result
changed_when: "'Organization host set to' in decidim_org_result.stdout"
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "β
Decidim | Ensure administrator user exists with correct credentials"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
IFS= read -r DECIDIM_ADMIN_PASSWORD && export DECIDIM_ADMIN_PASSWORD && container exec -i -e RAILS_ENV={{ ENVIRONMENT | quote }}
-e DECIDIM_ADMIN_EMAIL={{ lookup('users', 'platform_administrator').email | quote }}
-e DECIDIM_ADMIN_PASSWORD
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails runner -
args:
stdin: |-
{{ lookup('users', 'platform_administrator').password }}
{{ lookup('file', 'ruby/ensure/admin_user.rb') }}
register: decidim_admin_result
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
changed_when: "'Admin user ready' in decidim_admin_result.stdout"
delegate_to: "{{ DECIDIM_HOST_NODE }}"
- name: "π§ Decidim | Configure OIDC omniauth settings in organization"
ansible.builtin.shell: > # nocheck: container-exec-resolver DECIDIM_LOCAL_CID resolved at delegate_to runtime
container exec -i -e RAILS_ENV={{ ENVIRONMENT | quote }}
{{ DECIDIM_LOCAL_CID | quote }}
bundle exec rails runner -
args:
stdin: "{{ lookup('file', 'ruby/configure_oidc.rb') }}"
register: decidim_oidc_result
changed_when: "'OIDC settings configured' in decidim_oidc_result.stdout"
when: DECIDIM_OIDC_ENABLED | bool
delegate_to: "{{ DECIDIM_HOST_NODE }}"