Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to control the ruby version for puppet apply? #63

Closed
metmajer opened this issue Aug 17, 2015 · 12 comments
Closed

Any way to control the ruby version for puppet apply? #63

metmajer opened this issue Aug 17, 2015 · 12 comments

Comments

@metmajer
Copy link

I am not sure if what I am asking for can be achieved easily. The problem I have is that during the Puppet run and during the test run I require functionality from Ruby that is not available on those versions that come preinstalled on most platforms I would like to support.

Is there any way to specify a ruby version which would then get installed and applied to the puppet apply execution? Thanks!

@metmajer metmajer changed the title Any way to control the ruby version for puppet? Any way to control the ruby version for puppet apply? Aug 17, 2015
@neillturner
Copy link
Owner

unfortunately on centos 6 puppet will only work on ruby 187 while many of the tools like serverspec etc need ruby 1.9 or above.
using centos 7 puppet using ruby 2.1 i think which is much better.
ubuntu has long stopped using ruby 187 so that is ok.
The easiest way to add a new version of ruby to centos 6 that will co-exist with a version already installed via yum is to Install ruby via SCL
this allows you to install ruby 193 even if ruby 187 is installed
my kitchen_ansible code does this:
see https://github.com/neillturner/kitchen-ansible/blob/master/lib/kitchen/provisioner/ansible_playbook.rb
and more info
http://wiki.centos.org/AdditionalResources/Repositories/SCL

I've also install gitlab (a ruby on rail app) via https://github.com/sbadia/puppet-gitlab
this install rbenv to install a different ruby version for the application so this is a way to do it
if you need it for an application.

@grubernaut
Copy link
Contributor

If you install puppet as a ruby gem, it will use the version of ruby inside that ruby environment that the gem is installed as. One way around this, is to install puppet during test-kitchen provisioning, such that the kitchen-puppet provisioner doesn't install puppet. You can do this with vagrant, by passing in a custom Vagrantfile template that contains an extra inline shell provisioner to install the version of puppet+ruby that you want. Or you can use Docker and add extra RUN statements during the docker image creation with the kitchen-docker driver.

I've used both to install set versions of puppet without relying on the kitchen-puppet provisioner to install puppet.

@grubernaut
Copy link
Contributor

@metmajer were you able to solve this issue with a custom vagrantfile template, and/or a different solution?

@metmajer
Copy link
Author

metmajer commented Sep 6, 2015

I am currently trying to work out a solution that works for me. I'll promise to close the issue when I have come up with something and document it here. Thanks!

@metmajer
Copy link
Author

metmajer commented Sep 8, 2015

@grubernaut I have tried to follow your approach on providing a Docker image that has ruby (v2.2.0) and puppet (v4.2.1) installed as a gem. However, kitchen-puppet does not detect the puppet installation:

  1. The Docker container I prepared contains a symlink to puppet in /usr/bin/puppet:
# ls -la /usr/bin/puppet 
/usr/bin/puppet -> /root/.rbenv/versions/2.2.0/bin/puppet

and also a lookup using which returns a proper result:

# which puppet
/root/.rbenv/shims/puppet
  1. When I run kitchen converge, I do see the following lines in the output:
Installing puppet from yum on centos
which: no puppet in (/usr/local/bin:/bin:/usr/bin)
...
---> Package puppet.noarch 0:3.8.2-1.el6 will be installed
...
--> Processing Dependency: ruby >= 1.8.7 for package: puppet-3.8.2-1.el6.noarch

I am using the latest kitchen-puppet (v1.0.32). The Docker image I have come up with can be inspected here: https://github.com/dynaTrace/Dynatrace-Docker-Testing/tree/master/CentOS-6-Puppet.

Any ideas what I could change? Thanks!

@grubernaut
Copy link
Contributor

In my current org's setup, we install puppet via gem, and the binary is located at /usr/local/bin.

Maybe this would allow kitchen-puppet to see the binary?

@metmajer
Copy link
Author

metmajer commented Sep 8, 2015

Here are some findings:

  • symbolic links don't work, use a ln instead of ln -s
  • link puppet into /usr/bin not /usr/local/bin, as puppet will execute under sudo and sudo won't find any binaries in /usr/local/bin as it is not configured as a sudo `secure_path``

This will allow puppet apply to execute under sudo. Right now, I am getting the following error:

**Error: Could not parse application options: invalid option: --manifestdir=/tmp/kitchen/manifests**
...
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [   sudo -E puppet apply /tmp/kitchen/manifests/server/init.pp --modulepath=/tmp/kitchen/modules --manifestdir=/tmp/kitchen/manifests --fileserverconfig=/tmp/kitchen/fileserver.conf

Seems like --manifestdir is gone for good. This probably requires a change in kitchen-puppet. Any clue which version can safely be used?

@grubernaut
Copy link
Contributor

Ah looks like manifestdir was deprecated in puppet4. We'll have to change the way this is called in kitchen-puppet.

Opening a new issue for this bug

@metmajer
Copy link
Author

metmajer commented Sep 8, 2015

Yup. Please observe that --manifestdir is set even if provisioner.manifests_path is not set in .kitchen.yml. Maybe this could be a quick fix if you only set it if it's explicitly defined.

@grubernaut
Copy link
Contributor

Yup, looks like that is the case
https://github.com/neillturner/kitchen-puppet/blob/master/lib/kitchen/provisioner/puppet_apply.rb#L674

Although I'm unsure why the check is for puppet_environment instead of manifest_dir

@metmajer
Copy link
Author

metmajer commented Sep 8, 2015

Note: if you just omit the provisioner.manifests_path, the test manifests (e.g. in test/integration/do not get copied into the VM. I have commented out https://github.com/neillturner/kitchen-puppet/blob/master/lib/kitchen/provisioner/puppet_apply.rb#L674 and provisioning runs with puppet 4.2.1.

@grubernaut
Copy link
Contributor

Good to know, thanks!

I'm sure someone will work on this issue shortly. If not, I should be able to get to it next week, but am fairly swamped this week

@metmajer metmajer closed this as completed Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants