Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
remove facts
  • Loading branch information
b4ldr committed Sep 27, 2017
1 parent cb5266f commit 3c0322c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 89 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*cloudimg-console.log
.bundle/
Gemfile.lock
coverage/
Expand All @@ -6,3 +7,4 @@ coverage/
vendor/
packer_cache/
*.box
*.sw?
70 changes: 12 additions & 58 deletions facts/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,26 +16,19 @@ 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"
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-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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -166,20 +120,20 @@ 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"
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 "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"
Expand Down
9 changes: 9 additions & 0 deletions facts/generate_facts.sh
Original file line number Diff line number Diff line change
@@ -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
69 changes: 38 additions & 31 deletions facts/get_facts.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/bin/bash

#!/bin/sh
export PATH=/opt/puppetlabs/bin:$PATH

if test -f /usr/bin/apt-get; then
apt-get update
apt-get install -y lsb-release
lsbdistcodename=$(lsb_release -sc)
operatingsystem=$(lsb_release -si)
operatingsystemmajrelease=$(lsb_release -sr)
lsbdistcodename=`lsb_release -sc`
operatingsystem=`lsb_release -si`
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
Expand All @@ -23,65 +24,71 @@ case "${osfamily}" in
rpm -ivh /tmp/puppetlabs-release-pc1.rpm
for puppet_agent_version in 1.5.3-1 1.6.0-1 1.6.1-1 1.6.2-1 1.7.0-1; do
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}
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}
done
;;
'RedHat')
wget "https://yum.puppetlabs.com/puppetlabs-release-pc1-el-${operatingsystemmajrelease}.noarch.rpm" -O /tmp/puppetlabs-release-pc1.rpm
rpm -ivh /tmp/puppetlabs-release-pc1.rpm
for puppet_agent_version in 1.2.2 1.4.2 1.5.3 1.10.4; do
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}
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}
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}
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}
done
apt-get install -y make gcc libgmp-dev
;;
'FreeBSD')
pkg update -y
pkg install -y puppet4 rubygem-bundler
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:]')
operatingsystemrelease=$(facter operatingsystemrelease)
operatingsystemmajrelease=$(facter operatingsystemmajrelease)
hardwaremodel=$(facter hardwaremodel)
operatingsystem=`facter operatingsystem | tr '[:upper:]' '[:lower:]'`
operatingsystemrelease=`facter operatingsystemrelease`
operatingsystemmajrelease=`facter operatingsystemmajrelease`
hardwaremodel=`facter hardwaremodel`

[ "${hardwaremodel}" = 'amd64' ] && hardwaremodel=x86_64

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)
output_file="/vagrant/$(bundle exec facter --version | cut -c1-3)/${operatingsystem}-${operatingsystemrelease}-${hardwaremodel}.facts"
output_file="/vagrant/`bundle exec facter --version | cut -c1-3`/${operatingsystem}-${operatingsystemrelease}-${hardwaremodel}.facts"
;;
*)
output_file="/vagrant/$(bundle exec facter --version | cut -c1-3)/${operatingsystem}-${operatingsystemmajrelease}-${hardwaremodel}.facts"
output_file="/vagrant/`bundle exec facter --version | cut -c1-3`/${operatingsystem}-${operatingsystemmajrelease}-${hardwaremodel}.facts"
;;
esac
mkdir -p $(dirname $output_file)
[ -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 ||
FACTER_GEM_VERSION="~> ${version}" bundle exec facter -j | tee $output_file
Expand Down

0 comments on commit 3c0322c

Please sign in to comment.