How do I change the puppet version installed by vagrant - puppet

I use vagrant 1.0.1 on a precise32 base box to play with puppet.
Provisioning works fine, my manifests are being executed.
By default vagrant installs puppet 2.7.14 under /opt/vagrant_ruby/bin/puppet on the guest.
How can I configure vagrant (or who ever installs puppet on the guest) to use a more recent version like puppet 3.0 or 3.1?

Also you could update puppet with shell provisioner specified before puppet provisioner. As said in Vagrant documentation:
Multiple config.vm.provision methods can be used to define multiple provisioners. These provisioners will be run in the order they're defined. This is useful for a variety of reasons, but most commonly it is used so that a shell script can bootstrap some of the system so that another provisioner can take over later.
Here is example Vagrantfile for CentOS 6:
# Update puppet to version 3.2.2 before using puppet provisioning.
$puppet_update_script = <<SCRIPT
[ `rpm -qa puppetlabs-release` = 'puppetlabs-release-6-7.noarch' ] || rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm
[ `rpm -qa puppet` = 'puppet-3.2.2-1.el6.noarch' ] || yum -y update-to puppet-3.2.2
SCRIPT
config.vm.provision :shell, :inline => $puppet_update_script
# Puppet-3.2.2 provisioning here
config.vm.provision :puppet do |puppet|
puppet.options = '--parser future'
puppet.manifests_path = 'puppet/manifests'
end

You need to rebuild the basebox that you are using in vagrant and install whatever version of Puppet you want. I did the same for Cent 6.3 w/puppet 3.0. The Veewee gem is a great utility to building and managing Vagrant baseboxes for Oracle Virtualbox.

Related

Installing a handmade puppet module changed in Debian stretch

In debian jessie, I used to install my own handmyde puppet module in a subfolder in /etc/puppet/modules. I simply created a foder there with git:
cd /etc/puppet/modules
git clone https://github.com/ffnord/ffnord-puppet-gateway ffnord
from then on, I could use the module ffnord in my puppet scripts.
This does not work in Debian stretch any more. How can I install my module in Debaian 9?
The modules folder changed to
/etc/puppet/code/modules
You find out with
$ sudo puppet config print modulepath
/etc/puppet/code/modules:/usr/share/puppet/modules
A better path would be /usr/share/puppet/modules.
see https://puppet.com/docs/puppet/4.10/dirs_modulepath.html

Group Install "GNOME Desktop"

Puppet Version: 3.8.7
I have been working on building some system monitoring boxes and have ran into an issue when it comes to installing group yum packages. The normal course of installing packages of course isn't working but I figured that I would at least be able to work around this by including an exec to run the install as a command (like below):
exec { "GNOME Desktop":
command => "/usr/bin/yum -y groups install 'GNOME Desktop'",
timeout => 600,
}
There is an available module on the puppet forge that seems to do what I want but it's not compatible with our version of puppet and we are not in a place to upgrade at this time.
I also tried the setup that was listed in the below server fault question but it also did not work for me:
https://serverfault.com/questions/127460/how-do-i-install-a-yum-package-group-with-puppet
I have also manually been able to run the following command but when I exec it as a puppet command, it fails:
/usr/bin/yum -y groups install "GNOME Desktop"
Why is this? I assumed that puppet is just issuing the command in the exact same way the terminal would?
Changing the time out (or removing it) had zero effect, the issue is with the version of puppet and the ability to install group packages. I ended up installing the desktop environment in my kickstart file and ran puppet for everything else.

Using puppet with terraform

I want to create an AWS instance using Terraform and run a Puppet module inside it. I have tried many modules from github and nothing seems to work. Has anyone tried this?
The way you basically have to do this is install puppet locally with a remote-exec provisioner and then either do an apply or agent execution. First, setup your instance resource like this:
resource "aws_instance" "instance_name" {
...
provisioner "remote-exec" {
script = "puppet.sh"
}
}
Swap out aws_instance for a different cloud provider if/when not using AWS (Azure, DO, GCE, etc.) Then, use the script to install Puppet, execute apply or the agent, and then uninstall Puppet (if you are not activelly managing the instance afterward, which you likely would not be in the cloud).
#!/bin/sh
# debian family example; swap out 'apt' and package names where necessary
# prep puppet
sudo apt-get update && sudo apt-get install ruby -y
sudo gem install --no-document puppet
# apply puppet
sudo puppet apply manifest.pp
# remove puppet
sudo gem uninstall -aIx
sudo apt-get remove ruby -y
sudo apt-get autoremove -y
There are some variations on this. For example, you can curl against your Puppet Master or subscribe to the Puppetlabs package repository to install Puppet AIO. You can also do puppet agent -t afterward instead of a puppet apply. This may be preferable as transferring your modules over to be used with apply can be onerous.
For a similar use case but using ansible instead of puppet, we use null_resource along with local-exec.
resource "null_resource" "lvm_housekeeping" {
triggers {
ebs_volume_ids = "${join(",", aws_volume_attachment.instance_ebs_attachment.*.volume_id)}"
}
provisioner "local-exec" {
command = "ANSIBLE_CONFIG=$HOME/'${var.ansible_repo_location}'/ansible.cfg ansible-playbook -u ec2-user -e target=all -i '${join(",",aws_instance.my_instance.*.private_ip)}, ' $HOME/'${var.ansible_repo_location}'/main.yml"
on_failure = "continue"
}
}

Vagrant Installation in Debian Os

I have been trying to install and set up vagrant in my local machine which runs on debian OS for PHP project.
As mentioned in the link https://www.virtualbox.org/wiki/Linux_Downloads, I followed all the setups listed for installing Virtual Box initially. After successful installation I tried installing Vagrant by downloading it from official website. Once all installation is done, I create a directory called website cd into it and gave the command
Vagrant init
For vagrant initialization. But vagrant returns me the following error. How to resolve this?
Vagrant experienced a version conflict with some installed plugins!
This usually happens if you recently upgraded Vagrant. As part of the
upgrade process, some existing plugins are no longer compatible with
this version of Vagrant. The recommended way to fix this is to remove
your existing plugins and reinstall them one-by-one. To remove all
plugins:
rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems
Note if you have an alternate VAGRANT_HOME environmental variable
set, the folders above will be in that directory rather than your
user's home directory.
The error message is shown below:
Bundler could not find compatible versions for gem "rest-client":
In Gemfile:
vagrant (= 1.7.0) ruby depends on
rest-client (~> 1.7) ruby
vagrant-share (>= 0) ruby depends on
rest-client (1.6.8)

Ansible: ufw is not a legal parameter in an ansible task or handler

Trying to run an ansible installation on ubuntu 14.04
ansible-playbook -i hosts ruby-webapp.yml -t swap,ruby,deploy,mysql,nginx,ufw,import_data
I get
ERROR: ufw is not a legal parameter in an Ansible task or handler
and I can't go forward with the rest of the installation.
ufw was was added as a system module to Ansible 1.6 (see http://docs.ansible.com/ufw_module.html).
You are probably running an older version of Ansible on your control node (i.e., the machine where you are invoking the ansible-playbook command). Check your version with:
ansible --version
Upgrading depends on how you installed Ansible originally, but if you installed it to your system as root using pip, you can probably use:
sudo pip install -U ansible
(The -U means "update")
Edit: Just realized that you might be running Ubuntu 14.04 as your control node so I checked to see what version you get when you install Ansible with apt-get. As of this writing, it installs version 1.5.4, so if that's how you installed it, you definitely have the wrong version. You probably want to uninstall the OS package version and use one of the recommended installation techniques: http://docs.ansible.com/intro_installation.html#running-from-source
Something like:
sudo apt-get remove ansible
sudo easy_install pip
sudo pip install ansible
If you are missing easy_install, you may install it with:
sudo apt-get install python-setuptools

Resources