Skip to content

Instantly share code, notes, and snippets.

@munhitsu
Created October 23, 2012 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save munhitsu/3938829 to your computer and use it in GitHub Desktop.
Save munhitsu/3938829 to your computer and use it in GitHub Desktop.
augeas/augtool + puppet update /etc/hosts file
$puppetmaster_ip = '8.8.8.8'
augeas { "puppetmaster_in_hosts_append":
context => "/files/etc/hosts",
changes => [
"set 01/ipaddr '${puppetmaster_ip}'",
"set 01/canonical puppet",
],
onlyif => "match *[ipaddr = '${puppetmaster_ip}'] size == 0"
} -> augeas { "puppetmaster_in_hosts_update":
context => "/files/etc/hosts",
changes => [
"set *[ipaddr = '${puppetmaster_ip}']/canonical puppet",
],
onlyif => "match *[ipaddr = '${puppetmaster_ip}'] size > 0",
require => Augeas["puppetmaster_in_hosts_append"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment