Roy*_*Roy 6 redhat centos ansible oracle-linux
Ansible 可以轻松确保进程在每个主机上运行。
我可以做这样的事情:
---
- hosts: app_cluster
tasks:
- name: Look for the "foo" process
shell: ps -ef | grep foo | grep -v grep
register: process_list
changed_when: false
- name: Start "foo" if needed
shell: nohup /bin/foo &
when: "process_list.stdout.find('foo') == -1"
Run Code Online (Sandbox Code Playgroud)
但是,我需要在整个集群中拥有特定进程的一个实例。IE。它可以在任何主机上运行,只要它在某处运行并且集群中任何地方只有一个这样的进程。
在 ansible playbook 中可能有一种方便的方法来做到这一点吗?
小智 1
您可以使用http://docs.ansible.com/ansible/playbooks_delegation.html#run-oncerun_once
中所述的参数,以便任务将仅在批次的第一台主机中运行。考虑到您无法指定顺序,但它在某种程度上是“可预测的”(更多信息请参见https://github.com/ansible/ansible/issues/10964)
归档时间: |
|
查看次数: |
11088 次 |
最近记录: |