Я пытаюсь отредактировать файл limit.com с помощью puppet. Мне нужно добавить строки в эти файлы. Я копирую пример из: http://docs.puppetlabs.com/guides/augeas.html а>
# /etc/puppet/modules/limits/manifests/conf.pp
define limits::conf (
$domain = "root",
$type = "soft",
$item = "nofile",
$value = "10000"
) {
# guid of this entry
$key = "$domain/$type/$item"
# augtool> match /files/etc/security/limits.conf/domain[.="root"][./type="hard" and ./item="nofile" and ./value="10000"]
$context = "/files/etc/security/limits.conf"
$path_list = "domain[.=\"$domain\"][./type=\"$type\" and ./item=\"$item\"]"
$path_exact = "domain[.=\"$domain\"][./type=\"$type\" and ./item=\"$item\" and ./value=\"$value\"]"
augeas { "limits_conf/$key":
context => "$context",
onlyif => "match $path_exact size != 1",
changes => [
# remove all matching to the $domain, $type, $item, for any $value
"rm $path_list",
# insert new node at the end of tree
"set domain[last()+1] $domain",
# assign values to the new node
"set domain[last()]/type $type",
"set domain[last()]/item $item",
"set domain[last()]/value $value",
],
}
и вариант использования:
limits::conf {
# maximum number of open files/sockets for root
"root-soft": domain => root, type => soft, item => nofile, value => 9999;
"root-hard": domain => root, type => hard, item => nofile, value => 9999;
}
Результат внутри limit.conf:
#@student - maxlogins 4
root hard nofile 9999
root soft nofile 9999
Как я могу поместить пробел или вкладки между значениями «root hard nofile & value». Я пытаюсь поместить пробел внутри «», попробуйте с регулярным выражением, но не работает. Спасибо