ansible滚动重新启动playboook

Cma*_*mag 1 ansible

伙计们,我想在每个主机上分别重新启动服务,并等待用户输入,然后再继续使用清单中的下一个主机。

当前,如果您具有以下条件:

- name: Restart something
  command: service foo restart
  tags:
    - foo
- name: wait
  pause: prompt="Make sure org.foo.FooOverload exception is not present"
  tags:
    - foo
Run Code Online (Sandbox Code Playgroud)

它只会提示一次,而实际上并没有达到预期的效果。

在每个主机上运行重新启动任务之前,等待用户输入的正确ansible语法是什么?

hel*_*loV 5

结合使用剧本的serial属性和step选项。

playbook.yml

- name: Do it
  hosts: myhosts
  serial: 1

  tasks:
  - shell: hostname 
Run Code Online (Sandbox Code Playgroud)

使用--step选项呼叫剧本

ansible-playbook playbook.yml --step
Run Code Online (Sandbox Code Playgroud)

系统将提示您输入每个主机。

    Perform task: shell hostname (y/n/c): y

    Perform task: shell hostname (y/n/c):  **************************************** 
    changed: [y.y.y.y]
    Perform task: shell hostname (y/n/c): y

    Perform task: shell hostname (y/n/c):  **************************************** 
    changed: [z.z.z.z]
Run Code Online (Sandbox Code Playgroud)

有关更多信息:开始和步骤