---

- block:
    - import_tasks: ../includes/webapps_set_install_mode.yml
      vars:
        root_dir: "{{ etherpad_root_dir }}"
        version: "{{ etherpad_version }}"
    - set_fact: etherpad_install_mode={{ install_mode }}
    - set_fact: etherpad_current_version={{ current_version | default('') }}
  tags: etherpad

- when: etherpad_db_pass is not defined
  block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{etherpad_root_dir }}/meta/ansible_dbpass"
    - set_fact: etherpad_db_pass={{ rand_pass }}
  tags: etherpad

- block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{etherpad_root_dir }}/meta/ansible_session_key"
    - set_fact: etherpad_session_key={{ rand_pass }}
  tags: etherpad

- when: etherpad_api_key is not defined
  block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{etherpad_root_dir }}/meta/ansible_api_key"
    - set_fact: etherpad_api_key={{ rand_pass }}
  tags: etherpad

- when: etherpad_admin_pass is not defined
  block:
    - import_tasks: ../includes/get_rand_pass.yml
      vars:
        - pass_file: "{{etherpad_root_dir }}/meta/ansible_admin_pass"
    - set_fact: etherpad_admin_pass={{ rand_pass }}
  tags: etherpad

- name: Check if web dir exists
  stat: path={{ etherpad_root_dir }}/web
  register: etherpad_web_dir
  tags: etherpad
