0

I have a multiple environments adn i classified them in groups and each group have multiple hosts

During execution of playbook i want user to enter the instruction so to do this i came across the pause module but problem is this it only runs for 1st host in the group and ignores all other hosts even though i set the when condition. Is there a way that this prompt can only be run for the servers mentioned in when condition.

- name: Reading user input to start/stop for aio or manually
        pause:
          prompt: "You want to stop Application from aio or manually "
        register: restartmethod
        when: deploypackages == "y" and (ansible_default_ipv4.address == "192.168.4.28" or ansible_default_ipv4.address == "192.168.5.28" or ansible_default_ipv4.address == "192.168.6.28" or ansible_default_ipv4.address == "192.168.7.28" )
2
  • Checking for IP adresses in a when condition is a bad approach - that's not how you should handle your inventory. Put your servers into groups instead. AFAIK prompts can only occur in the top most definition of a play.
    – Panki
    Jun 13, 2022 at 6:26
  • Yes, Servers are in group , and you are right Prompt are in only in top level definiation but i read(after googling) we can use pause module but problem is it only runs on first host of the group
    – OmiPenguin
    Jun 13, 2022 at 7:04

1 Answer 1

0
- name: Reading user input to start/stop for aio or manually
        pause:
          prompt: "You want to stop Application from aio or manually "
        run_once:  true (Remove this)
        register: restartmethod
        when: deploypackages == "y" and (ansible_default_ipv4.address == "192.168.4.28" or ansible_default_ipv4.address == "192.168.5.28" or ansible_default_ipv4.address == "192.168.6.28" or ansible_default_ipv4.address == "192.168.7.28" )

Remove the line run_once so it will execute on hosts when condition meets

1
  • Sorry, run_once was added for testing purposes. Now after removing it simply Skips it , even though the condition is there ansible_default_ipv4.address == "192.168.7.28"
    – OmiPenguin
    Jun 13, 2022 at 11:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .