Ansible - 仅提示组中特定主机的用户输入

Ansible - 仅提示组中特定主机的用户输入

我有多个环境,我将它们分组,每个组都有多个主机

在执行剧本期间,我希望用户输入指令,因此为此我遇到了暂停模块但问题是,它只为组中的第一台主机运行,并忽略所有其他主机,即使我设置了何时条件。有没有办法使此提示只能针对when条件中提到的服务器运行。

- 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" )

答案1

- 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" )

删除 run_once 行,以便当条件满足时它将在主机上执行

相关内容