Skip to content

Instantly share code, notes, and snippets.

@duritong
Last active August 29, 2015 14:22
Show Gist options
  • Save duritong/de3d2678adb37b0642da to your computer and use it in GitHub Desktop.
Save duritong/de3d2678adb37b0642da to your computer and use it in GitHub Desktop.
oh concat why oh concat where is your refresh
$ git clone https://github.com/electrical/puppet-lib-file_concat modules/file_concat
Cloning into 'modules/file_concat'...
remote: Counting objects: 276, done.
remote: Total 276 (delta 0), reused 0 (delta 0), pack-reused 276
Receiving objects: 100% (276/276), 42.34 KiB | 0 bytes/s, done.
Resolving deltas: 100% (99/99), done.
Checking connectivity... done.
$ cd modules/file_concat
$ git checkout -b v0.3.0 0.3.0
Switched to a new branch 'v0.3.0'
$ cd../..
$ cat >file_concat.pp<<END
file_fragment{'second':
content => 'second line',
tag => 'bla',
}
file_concat{'/tmp/bla':
tag => 'bla',
owner => $::id,
group => $::gid,
notify => Exec['/bin/echo meep'],
}
file_fragment{'first':
content => 'first line',
tag => 'bla',
}
exec{'/bin/echo meep':
refreshonly => true,
# subscribe => Concat['/tmp/bla']
# subscribe => File['/tmp/bla']
}
END
$ puppet apply --modulepath=modules/ file_concat.pp
Notice: Compiled catalog for foo in environment production in 0.37 seconds
Notice: /Stage[main]/Main/File_concat[/tmp/bla]/ensure: created
Notice: /Stage[main]/Main/Exec[/bin/echo meep]: Triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.04 seconds
$ cd modules/file_concat/
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ cd../..
$ rm /tmp/bla
$ puppet apply --modulepath=modules/ file_concat.pp
Notice: Compiled catalog for foo in environment production in 0.35 seconds
Notice: /Stage[main]/Main/File[/tmp/bla]/ensure: defined content as '{md5}d069eb9ed1f0c0d9a02eebf696822467'
Notice: /Stage[main]/Main/Exec[/bin/echo meep]: Triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.04 seconds
$ cat foo.pp
concat::fragment{'second':
content => 'second line',
target => '/tmp/bla',
}
concat{'/tmp/bla':
owner => $::id,
group => $::gid,
notify => Exec['/bin/echo meep'],
}
concat::fragment{'first':
content => 'first line',
target => '/tmp/bla',
}
exec{'/bin/echo meep':
refreshonly => true,
# subscribe => Concat['/tmp/bla']
# subscribe => File['/tmp/bla']
}
$ rm /tmp/bla
$ puppet apply --modulepath=modules/ foo.pp
Notice: Compiled catalog for foo in environment production in 0.38 seconds
Notice: /Stage[main]/Main/Concat[/tmp/bla]/File[/tmp/bla]/ensure: defined content as '{md5}c2905d133cafb9b890627d61bf9ff2d2'
Notice: Finished catalog run in 0.03 seconds
$ cd /tmp/
$ mkdir modules
$ git clone https://github.com/puppetlabs/puppetlabs-concat modules/concat
$ git clone https://github.com/puppetlabs/puppetlabs-stdlib modules/stdlib
$ cat >foo.pp<<END
concat::fragment{'second':
content => 'second line',
target => '/tmp/bla',
}
concat{'/tmp/bla':
owner => $::id,
group => $::gid,
}
concat::fragment{'first':
content => 'first line',
target => '/tmp/bla',
}
exec{'/bin/echo meep':
refreshonly => true,
subscribe => Concat['/tmp/bla']
}
END
$ puppet --version
3.8.1
$ puppet apply --modulepath=modules/ foo.pp
Notice: Compiled catalog for foo in environment production in 0.42 seconds
Notice: /Stage[main]/Main/Concat[/tmp/bla]/File[/tmp/bla]/ensure: defined content as '{md5}c2905d133cafb9b890627d61bf9ff2d2'
Notice: Finished catalog run in 0.02 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment