是否可以在“拉模式"下运行剧本? [英] Is it possible to run a playbook in "pull mode"?

查看:25
本文介绍了是否可以在“拉模式"下运行剧本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些剧本,可以在主主机上启动,并在远程主机上运行特定操作.这是一种推送"模式 - 活动由主控主机发起.

I have playbooks which I start on a master host and which run specific actions on remote hosts. This is a "push" mode - the activity is initiated by the master host.

我的几个主机在给定时间出现故障,并且在这种状态下显然无法运行剧本.这会导致主机是最新的,而其他主机则不是.

Several of my hosts are down at a given time and obviously fail to run the playbook when in such a state. This leads to hosts which are up-to-date, while others are not.

为了解决这个问题,我可以以常规方式(例如通过 cron)在主主机上运行剧本,但这并不是特别有效.

To fix this I could run the playbook on the master host in a regular way (via cron for instance) but this is not particularly effective.

Ansible 中是否有一种内置方式来逆转流程,即从远程主机启动一个可在主服务器上使用的剧本,然后在该远程主机上运行它?

Is there a built-in way in Ansible to reverse the flow, that is to initiate from a remote host a playbook available on the master, to run it on that remote host?

我可以想象远程主机可以通过 ssh 连接到主机(例如在启动时),然后以主机作为参数(或围绕该想法的其他东西)触发剧本,但我绝对更喜欢使用 Ansible 功能而不是重新发明它.

I can imagine that the remote host could ssh to the master (at boot time for instance) and then trigger the playbook with the host as a parameter (or something around that idea) but I would definitely prefer to use an Ansible feature instead of reinventing it.

推荐答案

有一个脚本叫做 ansible-pull 反转了 Ansible 的默认推送架构.Ansible 开发人员还提供了一个示例手册.

There is a script called ansible-pull which reverses the default push architecture of Ansible. There is also an example playbook from the Ansible developers available.

这篇关于是否可以在“拉模式"下运行剧本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆