- name: Fail if invalid action when: | config_links_action not in ['update', 'remove'] ansible.builtin.fail: msg: | Action parameter must be either 'update' or 'remove' - name: Create temporary directory ansible.builtin.tempfile: prefix: config-links state: directory register: config_links_repo - name: Run config-links block: - name: Checkout config-links repo # noqa: latest[git] # config-links is supposed to be always working if you just check it out. ansible.builtin.git: repo: 'https://github.com/egor-tensin/config-links.git' dest: '{{ config_links_repo.path }}' accept_hostkey: true - name: Run links-update when: config_links_action == 'update' ansible.builtin.command: cmd: '{{ config_links_repo.path }}/links-update' chdir: '{{ config_links_path }}' changed_when: true - name: Run links-remove when: config_links_action == 'remove' ansible.builtin.command: cmd: '{{ config_links_repo.path }}/links-remove' chdir: '{{ config_links_path }}' changed_when: true always: - name: Clean up ansible.builtin.file: path: '{{ config_links_repo.path }}' state: absent