CFEngine-如果安装了特定的软件包版本,则设置变量 [英] CFEngine - set variable if a specific package version is installed

查看:85
本文介绍了CFEngine-如果安装了特定的软件包版本,则设置变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个脚本需要使用不同版本的httpd(Apache)支持Fedora和Centos这两个服务器. CFEngine用于创建配置文件,它需要根据系统中安装的httpd版本将不同的部分放在文件中.如何根据安装的版本将变量设置为true/false,以便随后可以适当地生成文件?我能找到的所有示例仅涉及安装,升级或删除软件包.

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.

推荐答案

您可以使用packagesmatching获取当前安装的httpd版本.您可以将其与ifelsestrcmpregcmp结合使用,以便设置可以在模板中使用的不同变量和类.

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.

这篇关于CFEngine-如果安装了特定的软件包版本,则设置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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