Hook before Puppet compiles a catalog (for pulling update from GIT)

133 views
Skip to first unread message

Iakov Gan

unread,
Jun 7, 2014, 10:33:30 PM6/7/14
to puppet...@googlegroups.com
Hi, 

I wonder how i can pull updates from my GIT to puppet server? 

There is already a gitlab-webhook, that works fine and the only problem is that it takes >1 minute to get all environments updated. At the moment in my test lab i have about 20 environments managed by r10k. Update of one env is about 3 seconds, so when i make a change while debugging some puppet module, it is really annoying to wait 1 minute every single time.   

I use foreman, and i can just modify node.rb (external_nodes) to pull r10k update every time it is called (taking into account it is called twice per update of course). Is it the only way?

Regards,

Iakov 





Garrett Honeycutt

unread,
Jun 8, 2014, 12:49:30 PM6/8/14
to puppet...@googlegroups.com
On 6/7/14, 10:33 PM, Iakov Gan wrote:
> Hi,
>
> I wonder how i can pull updates from my GIT to puppet server?
>
> There is already a gitlab-webhook, that works fine and the only problem
> is that it takes >1 minute to get all environments updated. At the
> moment in my test lab i have about 20 environments managed by
> r10k. Update of one env is about 3 seconds, so when i make a change
> while debugging some puppet module, it is really annoying to wait 1
> minute every single time.
>
> I use foreman, and i can just modify node.rb (external_nodes
> <http://docs.puppetlabs.com/guides/external_nodes.html>) to pull r10k
> update every time it is called (taking into account it is called twice
> per update
> <https://groups.google.com/forum/#!msg/puppet-users/6-MqbV1P2ec/8I1g4Lc0NKsJ> of
> course). Is it the only way?
>
> Regards,
>
> Iakov
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/33cfd118-5607-4249-aef7-19bbb40e7775%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/33cfd118-5607-4249-aef7-19bbb40e7775%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Iakov,

Perhaps the prerun_command[1] configuration setting might help. It
allows you to run a command before every agent run. I use it to run r10k.

[1] -
http://docs.puppetlabs.com/references/latest/configuration.html#preruncommand

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

Peter Meier

unread,
Jun 9, 2014, 5:44:47 AM6/9/14
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Perhaps the prerun_command[1] configuration setting might help. It
> allows you to run a command before every agent run. I use it to run
> r10k.
>
> [1] -
> http://docs.puppetlabs.com/references/latest/configuration.html#preruncommand

But
>
this is on the agent side, and not the master.

What I would do to have instant git updates, is updating things based
on a server side git post-update hook (the place where you push the
code). If you do the script in a little intelligent way, you can speed
up that quite good to make it pretty fast.

~pete

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlOVgfgACgkQbwltcAfKi38ObACeLB501PDamdCY4cR5X+bFFjgB
J8MAoJu/XATPpk1of4FJLGfAFV6pni9V
=hLSA
-----END PGP SIGNATURE-----

Iakov Gan

unread,
Jun 10, 2014, 3:08:14 AM6/10/14
to puppet...@googlegroups.com
Thanks for the hint, Peter. 

Looks like prerun_command is very interesting solution. BTW i've just found a puppet module for that[1]. 

But still using prerun_command  it can only pull ALL my environments before each puppet run (= 1min). I can't pull only one particular environment, can i?

I developed a small extension of node.rb, that does what i need: since node.rb knows environment of the node, i can call "r10k deploy environment #{your_env} -p". But the error management is quite difficult since i only can report error by exit code and no error message appears on the node unfortunately.  Any ideas?
 

Iakov Gan

unread,
Jun 10, 2014, 5:00:07 AM6/10/14
to puppet...@googlegroups.com
Sorry, i mixed up the names. Thank you both Garrett, Peter. 
Reply all
Reply to author
Forward
0 new messages