---
- name: Check if state is valid
  ansible.builtin.fail:
    msg: "Unknown state '{{ cinny_state }}'. Valid states are {{ cinny_states | join(', ') }}"
  when: cinny_state not in cinny_states

- name: Check if deployment method is supported
  ansible.builtin.fail:
    msg: "Deployment method '{{ cinny_deployment_method }}' is not supported! (supported are: {{ cinny_deployment_methods | join(', ') }})"
  when: cinny_deployment_method not in cinny_deployment_methods

- name: Include base configuration
  ansible.builtin.include_tasks:
    file: configure.yml

- name: Deploy tarball if required
  ansible.builtin.include_tasks:
    file: deploy-tarball.yml
  when: cinny_deployment_method in cinny_needs_tarball

- name: Deploy using {{ cinny_deployment_method }}
  ansible.builtin.include_tasks:
    file: "deploy-{{ cinny_deployment_method }}.yml"