Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active January 2, 2016 09:59
Show Gist options
  • Save raphink/8287200 to your computer and use it in GitHub Desktop.
Save raphink/8287200 to your computer and use it in GitHub Desktop.
define gordon::entry (
$ensure = present,
$section,
$key,
$value,
) {
case $ensure {
'present': {
$changes = [
"set section[.='${section}'] '${section}'",
"set section[.='${section}']/${key} '${value}'",
]
}
'absent': {
$changes = "rm section[.='${section}']/${key}"
}
default: {
fail "Wrong ensure value ${ensure}"
}
}
augeas { "Set gordon key ${section}/${key}":
incl => '/gordon.ini',
lens => 'IniFile.lns_loose',
changes => $changes,
}
}
$ augtool -r . --noautoload --transform "IniFile.lns_loose incl /gordon.ini" print /files
/files
/files/gordon.ini
/files/gordon.ini/section[1] = "application_stack"
/files/gordon.ini/section[1]/target_environment = "MYTEAM"
/files/gordon.ini/section[1]/custom_config_url = "https://myurl.com"
/files/gordon.ini/section[2] = "logger"
/files/gordon.ini/section[2]/log_file_path = "/var/log/tunnel_server/"
/files/gordon.ini/section[3] = "packet_capture"
/files/gordon.ini/section[3]/max_file_len = "10"
/files/gordon.ini/section[3]/snap_len = "100"
/files/gordon.ini/section[3]/capture_file_path = "/my/path/"
/files/gordon.ini/section[3]/capture_file_prefix = "myprefix"
/files/gordon.ini/section[4] = "log_server"
/files/gordon.ini/section[4]/log_server = "my.log.server"
/files/gordon.ini/section[4]/log_server_port = "12345"
/files/gordon.ini/section[4]/log_level = "DEBUG"
/files/gordon.ini/section[5] = "statistics_server"
/files/gordon.ini/section[5]/statsd_server = "my.stats.server"
/files/gordon.ini/section[5]/statsd_server_port = "9234"
/files/gordon.ini/section[6] = "tunnel_server_master"
/files/gordon.ini/section[6]/tunnel_server_master_id = "32"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment