03_launcher.ymlΒΆ

---
- name: "🧹 Clear the bootstrap marker of an earlier play"
  ansible.builtin.set_fact:
    DISCOURSE_REBUILT: false

- name: "🧹 Retire the launcher checkout of the URL-named layout"
  include_tasks:
    file: launcher/legacy_checkout.yml
    apply:
      become: true
  when: (DISCOURSE_REPOSITORY_LEGACY_RELPATH | split('/') | first) not in ['..', DISCOURSE_REPOSITORY_DIR | basename]

- name: ⬇️ Pull Discourse docker repository
  git:
    repo: "{{ DISCOURSE_REPOSITORY_URL }}"
    dest: "{{ DISCOURSE_REPOSITORY_DIR }}"
    version: "{{ DISCOURSE_REF }}"
    refspec: "{{ DISCOURSE_REF }}"
    update: true
    depth: 1
  register: discourse_repo_pull
  retries: 12
  delay: 30
  until: discourse_repo_pull is succeeded
  notify: rebuild-discourse
  become: true

- name: πŸ”§ set chmod 700 for '{{ DISCOURSE_CONTAINERS_DIR }}'
  ansible.builtin.file:
    path: "{{ DISCOURSE_CONTAINERS_DIR }}"
    mode: "700"
    state: directory

- name: "🌐 Deploy the network origins plugin to '{{ DISCOURSE_NETWORK_PLUGIN_HOST_DIR }}'"
  stack_host_copy:
    src: "ruby/plugins/infinito-network-origins/"
    dest: "{{ DISCOURSE_NETWORK_PLUGIN_HOST_DIR }}/"
    mode: "0644"
  notify: recreate-discourse

- name: "πŸ“‹ copy configuration to '{{ DISCOURSE_APPLICATION_YML_DEST }}'"
  stack_host_template:
    src: config.yml.j2
    dest: "{{ DISCOURSE_APPLICATION_YML_DEST }}"
    mode: "0640"
  notify: recreate-discourse

- name: "πŸ”‘ Record the digest of everything the bootstrap consumes"
  stack_host_copy:
    content: "{{ lookup('template', 'config.yml.j2') | from_yaml | dict2items | rejectattr('key', 'eq', 'env') | items2dict | to_json | hash('sha256') }}"
    dest: "{{ DISCOURSE_BOOTSTRAP_DIGEST_DEST }}"
    mode: "0640"
  notify: rebuild-discourse

- name: "βœ… Verify that '{{ DISCOURSE_CONTAINER }}' is running"
  ansible.builtin.command:
    argv:
      - container
      - ps
      - --filter
      - "name=^{{ DISCOURSE_CONTAINER }}$"
      - --filter
      - status=running
      - --format
      - "{{ '{{.Names}}' }}"
  register: docker_ps
  changed_when: docker_ps.stdout.strip() == ""
  failed_when: docker_ps.rc != 0
  notify: rebuild-discourse

- name: πŸ“‚ Load discourse handlers explicitly
  include_tasks: utils/load/handlers.yml
  vars:
    handler_role_name: "web-app-discourse"

- name: 🚿 flush, to recreate discourse app
  meta: flush_handlers