Skip to content

Commit

Permalink
Updates to fact gathering scripts
Browse files Browse the repository at this point in the history
- Fix CentOS 5 support
- Fix SLES 11/12 support
- Add openSUSE 15.0 support
  • Loading branch information
seanmil authored and rodjek committed Jul 11, 2019
1 parent 98fdf36 commit 75f5eb4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
11 changes: 8 additions & 3 deletions facts/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
config.vm.define "sles-11sp1-x86_64" do |host|
host.vm.box = "suse/sles11sp3"
host.vm.provision "shell", inline: "gem update --system"
host.vm.network "private_network", ip: "192.168.123.2"
host.vm.synced_folder ".", "/vagrant", type: "nfs"
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 "sles-12sp1-x86_64" do |host|
host.vm.box = "suse/sles12sp1"
host.vm.provision "shell", inline: "gem update --system"
host.vm.box = "idar/sles12sp3"
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 Expand Up @@ -221,6 +221,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
host.vm.provision "file", source: "Gemfile", destination: "Gemfile"
host.vm.provision "shell", path: "get_facts.sh"
end
config.vm.define "opensuse-15.0-x86_64" do |host|
host.vm.box = "opensuse/openSUSE-15.0-x86_64"
host.vm.provision "file", source: "Gemfile", destination: "Gemfile"
host.vm.provision "shell", path: "get_facts.sh"
end
config.vm.define "freebsd-12-x86_64" do |host|
host.vm.box = "bento/freebsd-12.0"
host.ssh.shell = '/bin/sh'
Expand Down
48 changes: 37 additions & 11 deletions facts/get_facts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ if test -f /usr/bin/zypper; then
zypper --non-interactive --gpg-auto-import-keys refresh
zypper --non-interactive install ruby-devel
osfamily='Suse'
# This is Leap which is based on SLES 12
if [[ `cat /etc/os-release |grep -e '^VERSION="42' -c` == 1 ]]; then
operatingsystemmajrelease=12
elif test -r /etc/os-release; then
operatingsystemmajrelease=$(. /etc/os-release ; echo ${VERSION} | cut -d. -f1)
else
operatingsystemmajrelease=$(cat /etc/SuSE-release | grep ^VERSION | cut -d' ' -f3)
fi
elif test -f /usr/bin/apt-get; then
apt-get update
apt-get install -y lsb-release
Expand Down Expand Up @@ -57,7 +65,15 @@ case "${osfamily}" in

;;
'RedHat')
wget "https://yum.puppetlabs.com/puppetlabs-release-pc1-el-${operatingsystemmajrelease}.noarch.rpm" -O /tmp/puppetlabs-release-pc1.rpm
if [[ ${operatingsystemmajrelease} -eq 5 ]]; then
# CentOS 5 can no longer wget the release file with HTTPS due to mis-matched SSL support:
http_method='http'
# The default CentOS repositories no longer work and prevent yum from working:
rm -f /etc/yum.repos.d/CentOS*
else
http_method='https'
fi
wget "${http_method}://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}
Expand Down Expand Up @@ -111,9 +127,14 @@ case "${osfamily}" in
[ ! -f ${output_file} ] && facter --show-legacy -p -j | tee ${output_file}
;;
'Suse')
if [[ `cat /etc/os-release |grep -e '^VERSION="42' -c` == 1 ]]; then
# This is Leap which is based on SLES 12
rpm -Uvh https://yum.puppet.com/puppetlabs-release-pc1-sles-12.noarch.rpm
if [[ ${operatingsystemmajrelease} -lt 12 ]]; then
# SLES 11 can no longer wget the release file with HTTPS due to mis-matched SSL support:
http_method='http'
else
http_method='https'
fi
if [[ ${operatingsystemmajrelease} -le 12 ]]; then
rpm -Uvh ${http_method}://yum.puppet.com/puppetlabs-release-pc1-sles-${operatingsystemmajrelease}.noarch.rpm
zypper --gpg-auto-import-keys --non-interactive refresh
for puppet_agent_version in 1.6.2 1.7.2 1.8.3 1.9.3 1.10.8; do
zypper --non-interactive install puppet-agent-${puppet_agent_version}
Expand All @@ -122,14 +143,19 @@ case "${osfamily}" in
facter --show-legacy -p -j | tee ${output_file}
done
zypper --non-interactive remove puppetlabs-release-pc1
rpm -Uvh https://yum.puppet.com/puppet5/puppet5-release-sles-12.noarch.rpm
for puppet_agent_version in 5.0.1 5.1.0 5.2.0 5.3.2; do
zypper --non-interactive install puppet-agent-${puppet_agent_version}
output_file="/vagrant/$(facter --version | cut -d. -f1,2)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
mkdir -p $(dirname ${output_file})
facter --show-legacy -p -j | tee ${output_file}
done
fi
if [[ ${operatingsystemmajrelease} -le 12 ]]; then
pup5vers="5.0.1 5.1.0 5.2.0 5.3.2 5.4.0 5.5.8"
else
pup5vers="5.5.8 5.5.10"
fi
rpm -Uvh ${http_method}://yum.puppet.com/puppet5/puppet5-release-sles-${operatingsystemmajrelease}.noarch.rpm
for puppet_agent_version in ${pup5vers}; do
zypper --gpg-auto-import-keys --non-interactive install puppet-agent-${puppet_agent_version}
output_file="/vagrant/$(facter --version | cut -d. -f1,2)/$(facter operatingsystem | tr '[:upper:]' '[:lower:]')-$(facter operatingsystemmajrelease)-$(facter hardwaremodel).facts"
mkdir -p $(dirname ${output_file})
facter --show-legacy -p -j | tee ${output_file}
done
;;
'Archlinux')
pacman -Syu --noconfirm ruby puppet ruby-bundler
Expand Down

0 comments on commit 75f5eb4

Please sign in to comment.