简体   繁体   English

确保木偶在配置文件中存在

[英]Ensure block exists in config file with puppet

After this existing block 在此现有块之后

prefix 2a03:2267:4e6f:7264:0000:0000:0000:0000/64
 {
 };

I want to add a new block, if it doesn't exist already: 我想添加一个新的块(如果尚不存在):

prefix fdda:fee6:0187:0000:0000:0000:0000:0000/64
 {
 };

in /etc/radvd.conf ( not at the end of the file) /etc/radvd.conf (不在文件末尾)

and then /etc/init.d/radvd restart 然后/etc/init.d/radvd restart

How do I manage this with puppet? 如何用with来管理这个?

Install 安装

puppet module install puppetlabs-stdlib

Then create a script addblock.pp: 然后创建脚本addblock.pp:

file_line { "ensure $line in /etc/radvd.conf":
    path  => '/etc/radvd.conf',
    line  => "prefix fdda:fee6:0187:0000:0000:0000:0000:0000/64\n{\n};",
}


exec { "restart":
  command => '/etc/init.d/radvd restart',
  provider => shell,
  require => File_line["ensure $line in /etc/radvd.conf"],
}

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

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