hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

puppet-apply provisioner cannot install puppet (enhance request) #10089

Open darkn3rd opened 6 years ago

darkn3rd commented 6 years ago

Enhancement request. Install puppet agent. At some point, it used to install puppet agent, but doesn't seem to do this anymore, as per current docs.

Vagrant version

Vagrant 2.1.2

Host operating system

ProductName:    Mac OS X
ProductVersion: 10.13.5
BuildVersion:   17F77

Guest operating system

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:    16.04
Codename:   xenial

Vagrantfile

Vagrant.configure('2') do |config|
  config.vm.box = 'bento/ubuntu-16.04'
  config.vm.network 'forwarded_port', guest: 80, host: 8081
  config.vm.provision 'puppet'
end

Debug output

https://gist.github.com/darkn3rd/9eb6f98b77680b8ed49bd2ce2c8602c5

Expected behavior

Puppet would be installed and work.

Actual behavior

Puppet is not installed

Steps to reproduce

  1. vagrant up

mkdir manifests
cat <<<-MANIFEST > manifests/default.pp
class hello_puppet {
  package { 'apache2':
    ensure => present,
  }
  service { 'apache2':
    ensure => running,
    enable => true,
  }
}
MANIFEST
briancain commented 6 years ago

Does your machine have anything inside of /opt/puppetlabs/bin/puppet? Is puppet installed on your guest? According to the docs, Vagrant will not install Puppet and expects it to be installed on your guest for the Puppet Apply provisioner to work: https://www.vagrantup.com/docs/provisioning/puppet_apply.html#bare-minimum

Thanks!

darkn3rd commented 6 years ago

That is why this is an enhancement request. This is an enhancement request to add the capability for installations.

All other provisioners have this capability, so puppet is the only one that does not have the ability to bootstrap the agent on the system.

darkn3rd commented 6 years ago
#!/bin/sh
command -v puppet > /dev/null && { echo "Puppet is installed! skipping" ; exit 0; }

ID=$(cat /etc/os-release | awk -F= '/^ID=/{print $2}' | tr -d '"')
VERS=$(cat /etc/os-release | awk -F= '/^VERSION_ID=/{print $2}' | tr -d '"')

case "${ID}" in
  centos|rhel)
    wget https://yum.puppet.com/puppet5/puppet5-release-el-${VERS}.noarch.rpm
    rpm -Uvh puppet5-release-el-${VERS}.noarch.rpm
    yum install -y puppet-agent
    ;;
  fedora)
    rpm -Uvh https://yum.puppet.com/puppet5/puppet5-release-fedora-${VERS}.noarch.rpm
    yum install -y puppet-agent
    ;;
  debian|ubuntu)
    wget https://apt.puppetlabs.com/puppet5-release-$(lsb_release -cs).deb
    dpkg -i puppet5-release-$(lsb_release -cs).deb
    apt-get -qq update
    apt-get install -y puppet-agent
    ;;
  *)
    echo "Distro '${ID}' not supported" 2>&1
    exit 1
    ;;
esac
petems commented 6 years ago

https://github.com/petems/vagrant-puppet-install might help with this 👍

briancain commented 6 years ago

Thanks for the script! However I am expecting the actual implementation to be a lot more complex than this. We'll need windows support (and other guests that puppet agents can run on), the ability to configure which version of puppet you are installing (to support older modules), and unit tests. Probably more that I am forgetting? An example of this pattern would be the docker provisioner, which has a similar architecture within vagrant as a provisioner. I'm writing this all up now as a starting point for future reference for anyone who decides to pick up this task.

lindes commented 1 year ago

I notice this is flagged as needs-community-help... Based on prior comments, I guess what's hoped for is for someone to follow the pattern outlined for Docker, and build out a cap directory in provisioners/puppet, to support various OS's? Is that correct?

I notice that several of the existing provisioners that do do this depend on a downloadable shell script from the vendor of the underlying software (e.g. in omnibus.rb for Chef, which then gets called after manually installing curl in the various ways specific to an OS...)

Could this not be done with direct installers in the various nix OSes, at least? I don't really do Windows, so I'm not sure how I'd even begin to deal with that one, but I also notice that, for example, the docker provisioner can't (at least if I'm understanding this code correctly) install on windows, it can only check to see if it's running, yes? So, perhaps something similar could be done here, and in the places where it's possible, apt/yum/whatever could just be run in the appropriate incantation in a collection of `provisioners/puppet/cap//puppet_install.rb` files? Yes? Seems straightforward enough... I'd have to download a bunch of new-to-me boxes and figure some things out, but I might be up for that. If not, hopefully this (and/or any response in garners) will give additional ideas on how this could be done.