diff --git a/.gitignore b/.gitignore index 8c55cde8..f7fb3526 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*cloudimg-console.log .bundle/ Gemfile.lock coverage/ @@ -6,3 +7,4 @@ coverage/ vendor/ packer_cache/ *.box +*.sw? diff --git a/facts/Vagrantfile b/facts/Vagrantfile index e8f57c92..f76b050e 100644 --- a/facts/Vagrantfile +++ b/facts/Vagrantfile @@ -8,13 +8,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.hostname = "foo.example.com" - config.vm.define "debian-6-x86_64" do |host| - host.vm.box = "puppetlabs/debian-6.0.10-64-nocm" - host.vm.provision "shell", inline: "apt-get update && apt-get install -y ruby rubygems" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end config.vm.define "debian-7-x86_64" do |host| host.vm.box = "puppetlabs/debian-7.8-64-nocm" host.vm.provision "shell", inline: "apt-get update && apt-get install -y ruby rubygems ruby-dev" @@ -23,7 +16,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", inline: "/sbin/shutdown -h now" end config.vm.define "debian-8-x86_64" do |host| - host.vm.box = "camptocamp/debian-8-amd64" + host.vm.box = "puppetlabs/debian-8.2-64-puppet" host.vm.provision "shell", inline: "apt-get update && apt-get install -y curl" host.vm.provision "shell", inline: "curl -sSL https://rvm.io/mpapis.asc | gpg --import - && \\curl -sSL https://get.rvm.io | bash -s stable" host.vm.provision "shell", inline: "source /etc/profile.d/rvm.sh && rvm install 1.9.3 && rvm use --create 1.9.3" @@ -31,18 +24,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" end - config.vm.define "ubuntu-10.04-x86_64" do |host| - host.vm.box = "ubuntu-server-10044-x64-vbox4210-nocm" - host.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box" - host.vm.provision "shell", inline: "apt-get update && apt-get install -y ruby ruby-dev rubygems libopenssl-ruby" - host.vm.provision "shell", inline: "gem install rubygems-update && /var/lib/gems/1.8/bin/update_rubygems" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-12.04-x86_64" do |host| - host.vm.box = "puppetlabs/ubuntu-12.04-64-nocm" - host.vm.provision "shell", inline: "apt-get update && apt-get install -y rubygems" + config.vm.define "debian-9-x86_64" do |host| + host.vm.box = "debian/contrib-stretch64" + host.vm.provision "shell", inline: "apt-get update && apt-get install -y curl" + host.vm.provision "shell", inline: "curl -sSL https://rvm.io/mpapis.asc | gpg --import - && \\curl -sSL https://get.rvm.io | bash -s stable" + host.vm.provision "shell", inline: "source /etc/profile.d/rvm.sh && rvm install 1.9.3 && rvm use --create 1.9.3" host.vm.provision "file", source: "Gemfile", destination: "Gemfile" host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" @@ -54,21 +40,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" end - config.vm.define "ubuntu-14.10-x86_64" do |host| - host.vm.box = "chef/ubuntu-14.10" - host.vm.provision "shell", inline: "apt-get update && apt-get install -y ruby ruby-dev" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-15.04-x86_64" do |host| - host.vm.box = "ubuntu/vivid64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "ubuntu-15.10-x86_64" do |host| - host.vm.box = "ubuntu/wily64" + config.vm.define "ubuntu-16.04-x86_64" do |host| + host.vm.box = "ubuntu/xenial64" host.vm.provision "file", source: "Gemfile", destination: "Gemfile" host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" @@ -80,18 +53,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" end - config.vm.define "ubuntu-16.04-x86_64" do |host| - host.vm.box = "ubuntu/xenial64" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end - config.vm.define "centos-5-x86_64" do |host| - host.vm.box = "puppetlabs/centos-5.11-64-nocm" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end config.vm.define "centos-6-x86_64" do |host| host.vm.box = "puppetlabs/centos-6.6-64-nocm" host.vm.provision "file", source: "Gemfile", destination: "Gemfile" @@ -104,13 +65,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" end - config.vm.define "fedora-19-x86_64" do |host| - host.vm.box = "chef/fedora-19" - host.vm.provision "shell", inline: "yum -y install ruby ruby-devel" - host.vm.provision "file", source: "Gemfile", destination: "Gemfile" - host.vm.provision "shell", path: "get_facts.sh" - host.vm.provision "shell", inline: "/sbin/shutdown -h now" - end config.vm.define "fedora-22-x86_64" do |host| host.vm.box = "bento/fedora-22" host.vm.provision "shell", inline: "dnf -y install gcc glibc-devel" @@ -166,7 +120,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", inline: "/sbin/shutdown -h now" end config.vm.define "freebsd-10-x86_64" do |host| - host.vm.box = "chef/freebsd-10.0" + host.vm.box = "bento/freebsd-10.3" host.vm.network :private_network, ip: '10.0.0.2' host.vm.synced_folder ".", "/vagrant", :nfs => true host.vm.provision "shell", inline: "pkg install -y devel/ruby-gems" @@ -174,12 +128,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" end - config.vm.define "freebsd-9-x86_64" do |host| - host.vm.box = "chef/freebsd-9.2" + config.vm.define "freebsd-11-x86_64" do |host| + host.vm.box = "bento/freebsd-11.1" host.vm.network :private_network, ip: '10.0.0.2' host.vm.synced_folder ".", "/vagrant", :nfs => true host.ssh.shell = '/bin/sh' - host.vm.provision "shell", inline: "pkg_add -F -r ruby19-gems" + host.vm.provision "shell", inline: "pkg install -y devel/ruby-gems" host.vm.provision "file", source: "Gemfile", destination: "Gemfile" host.vm.provision "shell", path: "get_facts.sh" host.vm.provision "shell", inline: "/sbin/shutdown -h now" diff --git a/facts/generate_facts.sh b/facts/generate_facts.sh new file mode 100755 index 00000000..c1974918 --- /dev/null +++ b/facts/generate_facts.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# This is a small script to spin up machines individuly as +# i dont have the disk space for them all +awk '$1=="config.vm.define" {print $2 }' Vagrantfile | tr -d '"' | while read BOX +do + echo "getting facts for ${BOX}" + vagrant up ${BOX} + vagrant destroy -f ${BOX} +done diff --git a/facts/get_facts.sh b/facts/get_facts.sh index 56d31478..fe8c7678 100755 --- a/facts/get_facts.sh +++ b/facts/get_facts.sh @@ -1,5 +1,4 @@ -#!/bin/bash - +#!/bin/sh export PATH=/opt/puppetlabs/bin:$PATH if test -f /usr/bin/apt-get; then @@ -10,11 +9,13 @@ if test -f /usr/bin/apt-get; then operatingsystemmajrelease=$(lsb_release -sr) osfamily='Debian' elif test -f /usr/bin/dnf; then - operatingsystemmajrelease=$(cat /etc/redhat-release | cut -d' ' -f3 ) + operatingsystemmajrelease=$(awk '{print $3}' /etc/redhat-release) osfamily='Fedora' elif test -f /usr/bin/yum; then - operatingsystemmajrelease=$(cat /etc/redhat-release | cut -d' ' -f4 | cut -c1) + operatingsystemmajrelease=$(awk '{print $3}' /etc/redhat-release| cut -c1) osfamily='RedHat' +else + osfamily=$(uname) fi case "${osfamily}" in @@ -25,7 +26,7 @@ case "${osfamily}" in dnf install -y "puppet-agent-${puppet_agent_version}.fedoraf${operatingsystemmajrelease}" output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts" mkdir -p $(dirname ${output_file}) - facter --show-legacy -p -j | tee ${output_file} + [ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file} done ;; 'RedHat') @@ -35,29 +36,34 @@ case "${osfamily}" in yum install -y puppet-agent-${puppet_agent_version} output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts" mkdir -p $(dirname ${output_file}) - facter --show-legacy -p -j | tee ${output_file} + [ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file} done ;; 'Debian') - if [[ "xenial" =~ ${lsbdistcodename} ]]; then - lsbdistcodename='wily' - fi - if [[ "serena" =~ ${lsbdistcodename} ]]; then - lsbdistcodename='xenial' - fi + case "${lsbdistcodename}" in + *xenial*) lsbdistcodename='wily' ;; + *serena*) lsbdistcodename='xenial' ;; + esac apt-get install -y wget wget "https://apt.puppetlabs.com/puppetlabs-release-pc1-${lsbdistcodename}.deb" -O /tmp/puppetlabs-release-pc1.deb dpkg --install /tmp/puppetlabs-release-pc1.deb apt-get update - for puppet_agent_version in 1.2.2 1.4.2 1.5.3; do + for puppet_agent_version in 1.10.7 1.2.2 1.4.2 1.5.3 1.10.6; do apt-get -y --force-yes install puppet-agent=${puppet_agent_version}* output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts" mkdir -p $(dirname ${output_file}) - facter --show-legacy -p -j | tee ${output_file} + [ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file} done apt-get install -y make gcc libgmp-dev ;; +'FreeBSD') + pkg update + pkg install -y sysutils/puppet5 sysutils/facter + output_file="/vagrant/$(facter --version | cut -c1-3)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts" + mkdir -p $(dirname ${output_file}) + [ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file} + ;; esac operatingsystem=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') @@ -71,7 +77,7 @@ PATH=/opt/puppetlabs/puppet/bin:$PATH gem install bundler --no-ri --no-rdoc --no-format-executable bundle install --path vendor/bundler -for version in 1.6.0 1.7.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0; do +for version in 1.6.0 1.7.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0; do FACTER_GEM_VERSION="~> ${version}" bundle update case "${operatingsystem}" in openbsd) @@ -81,6 +87,7 @@ for version in 1.6.0 1.7.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0; do output_file="/vagrant/$(bundle exec facter --version | cut -c1-3)/${operatingsystem}-${operatingsystemmajrelease}-${hardwaremodel}.facts" ;; esac + [ -f ${output_file} ] && continue mkdir -p $(dirname $output_file) echo $version | grep -q -E '^1\.' && FACTER_GEM_VERSION="~> ${version}" bundle exec facter -j | bundle exec ruby -e 'require "json"; jj JSON.parse gets' | tee $output_file ||