conditional within define in puppet

一世执手 提交于 2019-12-04 12:59:30

You are trying to embed an if block inside a resource declaration. Alas, this is not possible. The block must be global or in a regular block (e.g., class body, define body, lambda body).

In this case, you want to "amend" the package resource, so to speak. I like to use the following construct for this purpose:

package { $title:  
    ensure        => installed,  
    allow_virtual => true,  
    configfiles   => keep,  
}  
if $queryresponse {  
    Package[$title] {
        require      => File["/var/cache/debconf/pkg-${title}.seeds"],  
        responsefile => "/var/cache/debconf/pkg-${title}.seeds",  
    } 
}

Please note that this override syntax is only allowed in this scope because the require and responsefile attributes don't have any value assigned originally.

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