---
- name: Feature Deployment
  gather_facts: false
  hosts: all
  roles:
    - role: common
  vars_files:
    - ../vars/common.yml
  vars_prompt:
    - name: "feature_version"
      private: false
      prompt: "Enter the feature release version"
  tasks:
    - name: Ensure that feature_version prompt is not empty
      ansible.builtin.assert:
        that:
          - feature_version is defined
          - feature_version is string
          - feature_version | length > 0
        fail_msg: "feature_version is required"
    - name: Upload repo
      ansible.builtin.import_role:
        name: upload_repo
    - name: Trigger ecoffice.sh on remote host
      become: true
      become_user: wfidply
      ansible.builtin.shell: >
        /apps/DEVOPS/{{ feature_version }}/scripts/ecoffice.sh \
          {{ feature_version }}
      changed_when: false
      register: entrypoint_output
    - name: Check if ecoffice.sh was executed successfully
      ansible.builtin.assert:
        that:
          - entrypoint_output.rc == 0
        fail_msg: "ecoffice.sh failed to execute"
