简体   繁体   English

如何从人偶清单中调用人偶提供者方法?

[英]How to call a puppet provider method from puppet manifest?

I'm using the ibm_installation_manager module from the puppet forge and it is a bit basic because IBM wrote Installation Manager in a time where idempotency was done much. 我正在使用来自伪造伪造的ibm_installation_manager模块,这有点基础,因为IBM在做幂等的时候编写了Installation Manager。 ref: https://forge.puppet.com/puppetlabs/ibm_installation_manager 参考: https : //forge.puppet.com/puppetlabs/ibm_installation_manager

As such it does not cater nicely for upgrades - so the module will not detect if an upgrade is needed, stop existing processes, do the upgrade and then start the processes again. 因此,它不能很好地适应升级-因此该模块将不会检测是否需要升级,停止现有进程,进行升级然后再次启动进程。 It will just detect if an upgrade is needed and try to install the desired version and if that constitutes an upgrade that's great, but it will probably fail due to running instances. 它只会检测是否需要升级,然后尝试安装所需的版本,并且该版本是否构成了不错的升级,但是由于运行实例而可能会失败。

So I need to implement some "stop processes" pre-upgrade functionality. 因此,我需要实现一些“停止过程”升级前功能。

I need to mention at this point I'm new to ruby and fairly new to puppet. 在这一点上,我需要提一下,我是红宝石的新手,也是木偶的新手。

The provider that the module uses (imcl.rb) has an exists method. 模块使用的提供程序(imcl.rb)有一个exist方法。 The ideal way for me to detect if an upgrade is going to happen (and stop the instances if it is) would be for my puppet manifest to be able to somehow call the exists method. 对于我来说,检测升级是否将要发生(并停止实例)的理想方法是使我的木偶清单能够以某种方式调用exist方法。 Is this possible? 这可能吗?

Or how would you approach this problem? 或者您将如何解决这个问题? Something like imcl.exists(ibm_pkg["my_imcl_pkg_resource"]) 类似于imcl.exists(ibm_pkg [“ my_imcl_pkg_resource”])

The ideal way for me to detect if an upgrade is going to happen (and stop the instances if it is) would be for my puppet manifest to be able to somehow call the exists method. 对于我来说,检测升级是否将要发生(并停止实例)的理想方法是使我的木偶清单能够以某种方式调用exist方法。 Is this possible? 这可能吗?

No, it is not possible, at least not in any useful way. 不,这是不可能的,至少没有任何有用的方式。 Your manifests describe how to build a catalog of resources describing the target state of the machine. 您的清单描述了如何建立描述机器目标状态的资源目录 In a master / agent setup, this happens on the master. 在主服务器/代理设置中,这发生在主服务器上。 The catalog is then used as input to a separate step, in which it is transferred to the target machine and applied there. 然后,目录用作单独步骤的输入,在此步骤中,目录被传输到目标计算机并在那里应用 It is in this second step that providers are engaged. 在第二步中,提供商参与其中。

To the extent that you want the contents of your catalogs to be influenced by the current state of the target machine, the Puppet mechanism for that is to convey the needed state details to the catalog builder in the form of facts . 如果您希望目录的内容受目标计算机的当前状态影响,那么Puppet机制就是以事实的形式将所需的状态详细信息传达给目录构建器。 It is relatively straightforward to add your own facts. 添加您自己的事实相对简单。 Indeed, there are at least two distinct, non-exclusive mechanisms , going under the names "external facts" and "custom facts". 实际上,至少有两种截然不同的非排他性机制 ,分别以“外部事实”和“习惯事实”为名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM