tehmaspc / puppet-magnum

https://rubygems.org/gems/puppet-magnum
Other
30 stars 13 forks source link

New features #2

Closed AlexRRR closed 9 years ago

AlexRRR commented 9 years ago

Hello! first of all thanks for sharing your software, I have found it incredibly useful. So I decided not to be an ass and share a few tweaks that we have used the past few months which might be interesting for the project.

Configuration file

We use R10k, and find it incredibly useful. So I decided that it would be useful to have a configuration file which reads several configuration parameters (existing ones and new ones) and expects to find it in ~/.magnumrc the following is an example


---
  r10kdirectory: ~/localch/vcs/environments
  r10kenvironment: production
  vagrantbox: puphpet/debian75-x64
  mantainer_email: awesomedude@brokenstartup.com
  copyright_holder: brokenstartup AG

the r10kdirectory and r10kenvironment are used to point the VagrantFile to the correct location where the modules are deployed. vagrantbox allows to set a which box should be used. (used to be hardcoded before)

Vagrant file

The Vagrantfile now uses the r10kdirectory and r10kenvironment defined above and include then in the puppet provisioner. Also the box is defined in the config file.

note: I have not gotten around to add the relevant hiera parts to the Vagrantfile which would be definitively nice for the serverspec tests. Coming soon...

Hiera rspec support

We are using the profiles and roles pattern, and we use heavily hiera to separate data from code. I have modified the spec_helper.rb to dynamically setup the correct path for the hiera data, set a base hierarchy and create a data yaml file to test on. It will also add a basic parameter to the base spec tests so if needed it will match the created the hierachy.

  #mock the hostname so it matches the hiera
  #hierarchy when testing.
  let(:facts) { {:hostname => 'host-dev-dc01'} }

This snippet will make the hiera lookups match the data on fixtures/hiera/data/host-dev-dc01.yaml file based on the generated hierarchy.

gem versions

I bumped the versions here and there, and while they work for me they have their drawbacks (mainly rspec been too new for rspec-puppet and some deprecation warnings are shown). But I rather by in a more updated fashion than not.

That is all for now, again thanks for the great effort.

tehmaspc commented 9 years ago

Thanks @AlexRRR.

I'll have to take a look at this more closely when I get some time. I'm super happy that you have gotten some use from Magnum. The bulk of your changes are needed - esp. version bumps/etc. You definitely found some things that are 'leftovers' from when I used this tool internally at my prior job and we should change those - i.e. the 'magnum-vagrant' VM box.

There are a couple of things I'm not sure right now I can change in your PR since we need to keep all this as generic as possible but hopefully we can get most of your changes in. Ping me if I'm away for too long - haven't been doing Puppet work lately but I'd love to get your changes in ASAP.

Cheers, Tehmasp

AlexRRR commented 9 years ago

@tehmaspc thanks for the reply. Maybe the best way to go about this would be to close this pull request and I will create individual ones, so we can discuss them separately. I am actively using this so I will be adding updates as I go. I am a little busy right now, but I will try to make the time soon. Again thanks for sharing your tool.

tehmaspc commented 9 years ago

@AlexRRR - yeah; that sounds good. I was thinking for some things - like the versions of gems you could either create a separate PR or create an issue for this. If you create issues I can use this PR as a reference as well - that might be easier (time wise) for you. Thanks!