sensu / sensu-ansible

An Ansible role to deploy a fully dynamic Sensu stack!
https://ansible-sensu.readthedocs.io
MIT License
126 stars 96 forks source link

The 'pause' module bypasses the host loop, which is currently not supported in the free strategy and would instead execute for every host in the inventory list. #227

Open idelsink opened 4 years ago

idelsink commented 4 years ago

I get the following error:

ERROR! The 'pause' module bypasses the host loop, which is currently not supported in the free strategy and would instead execute for every host in the inventory list.

The error appears to be in '/home/username/.ansible/roles/sensu.sensu/tasks/rabbit.yml': line 53, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Wait for RabbitMQ to be up and running before asking to create a vhost
  ^ here

The following statement uses a pause to wait for something: https://github.com/sensu/sensu-ansible/blob/9db24c810a4480f7bbf70c7de63d9220aa9f63c9/tasks/rabbit.yml#L53-L57

I'm running ansible ansible 2.9.1 and am using version 5.4.0 of the sensu role.

Proposed solution

It would be better to use the wait_for option and to actually wait for RabbitMQ to be up and running.

jaredledvina commented 4 years ago

Hey @idelsink ,

Oh fun, I wonder if this is something new with updated versions of Ansible. If you're willing to PR the change, I'm happy to check it out. Would also be interested in the version of Ansible you're using and on what operating systems.

idelsink commented 4 years ago

Hi @jaredledvina ,

Yeah always fun when something seems to break. I'm running Ansible v2.9.1. For my OS i'm using Fedora 30 (soon to be 31) and Ubuntu 18.04.3 LTS as a target.

ansible 2.9.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ingmar/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.5 (default, Oct 17 2019, 12:09:47) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
idelsink commented 4 years ago

Interesting in te docs for the pause module it states:

Pauses playbook execution for a set amount of time, or until a prompt is acknowledged. All parameters are optional. The default behavior is to pause with a prompt. To pause/wait/sleep per host, use the wait_for module.

So I think that the most basic solution would be to replace it with the following:

- name: Wait for RabbitMQ to be up and running before asking to create a vhost
  tags: rabbitmq
  wait_for:
    timeout: 3
  when: sensu_rabbitmq_state is changed
Rohlik commented 2 years ago

I'm getting same error in our playbook for this task with strategy set to free even when new_node_name is defined 😢:

- name: Prompt for new_node_name if not defined
  ansible.builtin.pause:
    prompt: "Enter 'new_node_name' "
    register: new_node_name_prompt
  when: new_node_name is not defined