--- - name: Check if deployment method is supported ansible.builtin.fail: msg: >-2 Deployment method '{{ hydrogen_deployment_method }}' is not supported. Support methods are {{ hydrogen_deployment_methods | join(', ') }}. when: hydrogen_deployment_method not in hydrogen_deployment_methods - name: Check if state is supported ansible.builtin.fail: msg: >-2 State '{{ hydrogen_state }}' is not supported. Supported states are: {{ hydrogen_states | join(', ') }} when: hydrogen_state not in hydrogen_states - name: Ensure hydrogen user '{{ hydrogen_user }}' is {{ hydrogen_state }} ansible.builtin.user: name: "{{ hydrogen_user }}" system: "{{ hydrogen_user_system | default(true, true) }}" groups: "{{ hydrogen_user_groups | default(omit, true) }}" append: >-2 {{ hydrogen_user_append_groups | default(hydrogen_user_groups | default([]) | length > 0, true) | bool }} state: "{{ hydrogen_state }}" register: hydrogen_user_info - name: Ensure hydrogen config file is {{ hydrogen_state }} ansible.builtin.file: path: "{{ hydrogen_config_file }}" state: "{{ hydrogen_state }}" when: hydrogen_state == 'absent' - name: Ensure hydrogen config folder is {{ hydrogen_state }} ansible.builtin.file: path: "{{ hydrogen_config_file | ansible.builtin.basename }}" state: >-2 {{ (hydrogen_state == 'present') | ternary('directory', 'absent') }} owner: "{{ hydrogen_run_user_id }}" group: "{{ hydrogen_run_group_id }}" mode: "0755" - name: Ensure hydrogen config file is {{ hydrogen_state }} ansible.builtin.copy: dest: "{{ hydrogen_config_file }}" content: "{{ hydrogen_config | to_nice_json }}" owner: "{{ hydrogen_run_user_id }}" group: "{{ hydrogen_run_group_id }}" mode: "0640" when: hydrogen_state == 'present' - name: Deploy using {{ hydrogen_deployment_method }} ansible.builtin.include_tasks: file: "deploy-{{ hydrogen_deployment_method }}.yml"