Skip to content

Instantly share code, notes, and snippets.

@hfm
Forked from munhitsu/gist:3938829
Created June 4, 2016 15:45
Show Gist options
  • Save hfm/a52fb0fab43d416941cefaac0af78d7d to your computer and use it in GitHub Desktop.
Save hfm/a52fb0fab43d416941cefaac0af78d7d 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