CFEngine - set variable if a specific package version is installed

本秂侑毒 提交于 2019-12-25 08:13:41

问题


A script needs to support two servers, Fedora and Centos, with different versions of httpd (Apache). CFEngine is used to create the configuration file and it needs to put different sections to the file depending on which httpd version is installed in the system. How can I set a variable to true/false depending on which version is installed so that I can then generate the file appropriately? All the examples I could find only deal with installing, upgrading or removing packages.


回答1:


You could use packagesmatching to get the version of httpd that's currently installed. You might combine it with ifelse, strcmp, regcmp so that you can set different variables and classes which you might use in your template.




回答2:


I use CFEngine (3.9) on CentOS 7.3. This version sets a hard class centos. You can use this to create the different sections. (Is also sets a hard class redhat, because CentOS is a derived from RedHat). You can find the classes that are availabe on your system with:

cf-promises -v



来源:https://stackoverflow.com/questions/40078172/cfengine-set-variable-if-a-specific-package-version-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!