Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make action fail if no hosts were updated #86

Open
20k-ultra opened this issue Jan 4, 2024 · 1 comment
Open

make action fail if no hosts were updated #86

20k-ultra opened this issue Jan 4, 2024 · 1 comment

Comments

@20k-ultra
Copy link

I'm trying to get the use of this action to fail instead of pass when no hosts were updated. This can happen for various reasons but I don't want my CI to think the changes were actually deployed when no hosts were found from the inventory file.

This could also just be a configuration file to avoid introducing a breaking change.

Alternatively, I've tried to store the output of this action and grep it for no hosts matched but the issue is I need this action to write to GITHUB a output var. I can't just read the stdout of a step.

@20k-ultra
Copy link
Author

20k-ultra commented Jan 4, 2024

I've worked around the warning not causing a fail in this action by adding the following step to my playbook which makes a step fail.

- name: Check if host group is empty
  hosts: localhost
  any_errors_fatal: true
  gather_facts: no
  tasks:
    - name: Fail if hosts group is empty
      fail:
        msg: "Inventory for 'proxy' is empty. Exiting playbook."
      when: "'proxy' not in groups or (groups['proxy'] | length == 0)"

This is just undesirable since I have over 30 playbooks I'll need to add this to and continue to add this to new playbooks so I hope you consider adding a configurable fatal error on warn for no hosts matched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant