---
- name: "stop and remove discourse container if it exist"
  docker_container:
    name: "{{applications.discourse.container}}"
    state: absent
  register: container_action
  failed_when: container_action.failed and 'No such container' not in container_action.msg
  listen: recreate discourse
  
- name: "add central database temporary to {{application_id}}_default"
  command:
    cmd: "docker network connect {{applications.discourse.network}} central-{{ database_type }}"
  ignore_errors: true
  when: applications[application_id].features.database | bool
  listen: recreate discourse

- name: rebuild discourse
  command:
    cmd: "./launcher rebuild {{applications.discourse.container}}"
    chdir: "{{docker_repository_directory }}"
  listen: recreate discourse