Puppet, Vagrant and repos

88 views
Skip to first unread message

Andrei Maxim

unread,
Jul 7, 2014, 11:40:21 AM7/7/14
to puppet...@googlegroups.com
Hi,

I've been looking into Puppet recently and I'm trying to setup a couple
of virtual machines that should mimick what's in production. I'm pretty
much a developer trying to lean towards DevOps :-)

Locally, I'm using Vagrant and the CentOS 6.5 64-bit box with Puppet
3.4.3 that was published by Puppetlabs, which should somewhat mirror
what's on the servers (a custom AMI based on CentOS 6.5).

What I'm trying to do right now -- and I've found a bunch of ways to do
this -- is to setup a couple of repositories (EPEL and MySQL Community
being the most important ones). I've noticed that people do this in a
number of ways, from grabbing the RPM package to using the 'yumrepo'
type to adding a custom module for each repo or by using a general
purpose Yum module (like the one from example42) and specifying the
repos there.

Normally, when I install those repos, I download the RPM locally and
install it using the command line, for example:

yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

That RPM will create a number of entries in the /etc/yum.repos.d/,
which seems odd to add each one by hand using the `yumrepo` type.

I've seen this example given a number of times (it's also the correct
answer to a similar question on SO):

node default {
include base
}

class base {
yumrepo { "IUS":
baseurl =>
"http://dl.iuscommunity.org/pub/ius/stable/$operatingsystem/$operatingsystemrelease/$architecture",

descr => "IUS Community repository",
enabled => 1,
gpgcheck => 0
}
}

Then, for any node that extends base you can say
class foo {
package { "bar": ensure => installed, require => Yumrepo["IUS"] }
}

Going back to the example with the MySQL Community RPM, I would have to
manually do this for three repos (the other two are disabled):

* mysql-connectors-community
* mysql-tools-community
* mysql56-community

Is this still the accepted solution in the Puppet community? If so, how
would you organize those repositories? Create a module for each
repository? Create a repository module with all the sources?

And, somewhat related to this subject, I've noticed that I might get
some errors when provisioning my VMs because the base system wasn't up
to date. I was planning to add a `yum update` command to my setup, but
I realize that this might not be the best solution because I might not
want to update the base system everytime I run puppet.

What's the best way to update the system only when running Puppet for
the first time?

Thanks,
Max


Doug Forster

unread,
Jul 7, 2014, 12:01:51 PM7/7/14
to puppet...@googlegroups.com
Max,

I do a single module for each repo that I want added. In some cases I combine it with a repo to manage the service. IE mysql* repos would be managed via the mysql module.

As for making sure they are all up to date I might just create an
exec {my_check_update:
  refreshonly => true,
  command => "yum check-update",
}

I might even try to setup a global dependency in your site.pp. Someone else probably has a smarter idea though.
Yumrepo { notify => Exec[my_check_update] }

In case you may have missed it on all my vagrant boxes I run a yum check-update each time they are provisioned.
Vagrant.configure("2") do |config|
  config.vm.provision "shell",
    inline: "yum check-update"
end

Hope it helps. :)
Doug





--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/lpeenc%243ai%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Yanis Guenane

unread,
Jul 7, 2014, 1:50:04 PM7/7/14
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To second Doug, I also uses a module for each repo I want to add.
This way you can probably have a base profile, like the following :

class profile::base {

resources { 'yumrepo' :
purge => true,
}

include ::epel
include ::nginx
include ::repoforge
}

And only the module you specify will be enabled. It will be clear for
whoever look at the code which repo are to be enabled.

- --
Yanis Guenane
>> puppet-users...@googlegroups.com. To view this
>> discussion on the web visit https://groups.google.com/d/
>> msgid/puppet-users/lpeenc%243ai%241%40ger.gmane.org. For more
>> options, visit https://groups.google.com/d/optout.
>>
>

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

iQEcBAEBAgAGBQJTut2vAAoJEPh7fjCNYlpntCIH/3nT5kw7XLesDyUkP7fiE17H
gTl77/7bOHeJxHWWHeeTyzh5X/EjRYzl+sA/BasyLTMQjrAUFJc9ZP/ARFbOn1My
wuEBTpaeLzeH+pTMT6fER0vD0GsJVSnA2jasn5czT88Ql6PLGXfGhKJnI9NvKCe3
Ic5Hjuj+IKpTFMUQ+/ZznRdIKBiaMJ2+RLb/6kIFc/yYYoAMXZbMJMyeLhOwH1jK
iyKLMZjI98Bh2rz6mIZGK4Ey2f0r1QjqK/3wDiDMoERj/O+qM5vBRazxgSLXYra3
ewG0r7LQx8LNKgxSuKUMwYdTruPsZNMIm6o76cpFB6l2CuKlAQ9R4dK5rstUsng=
=r7Zl
-----END PGP SIGNATURE-----

Andrei Maxim

unread,
Jul 8, 2014, 3:26:32 AM7/8/14
to puppet...@googlegroups.com
Yanis, Doug, thank you very much.

Max

Thomas Bendler

unread,
Jul 14, 2014, 5:59:31 AM7/14/14
to puppet-users
I use a separate module for the repositories (https://forge.puppetlabs.com/thbe/yum) and require them during startup like here (https://forge.puppetlabs.com/thbe/ssmtp). So Puppet is doing the work to get everything in place in the correct order.

Regards Thomas


--
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+unsubscribe@googlegroups.com.



--
Linux ... enjoy the ride!
Reply all
Reply to author
Forward
0 new messages