Skip to content

Commit

Permalink
(maint) Cleanup Amazon repos
Browse files Browse the repository at this point in the history
Checking for osfamily == Amazon was a mistake, the osfamily will be
RedHat. Repo names on Amazon instances need to be handled specially;
they use EL 6 repos. Adds testing for Amazon OS.
  • Loading branch information
Michael Smith committed Mar 15, 2016
1 parent 5d01a8c commit 9e1796b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 40 deletions.
3 changes: 3 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ Alternate source from which you wish to download the latest version of Puppet.

This module supports [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix) except Solaris 11.

Amazon AMIs should also work and use EL 6 packages. The latest tested Amazon AMI is 2015.09.2.

###Known issues

* In masterless environments, modules installed manually on individual agents cannot be found after upgrading to Puppet 4.x. You should reinstall these modules on the agents with `puppet module install`.
Expand All @@ -110,6 +112,7 @@ Specifically in the 1.1.0 Release:
* For Windows, you must trigger an agent run after upgrading so that Puppet can create the necessary directory structures.
* Upgrading from 2015.2.x to 2015.3.x is not yet supported.
* Solaris 11 is not yet supported.
* AIX package names are based on PowerPC architecture version. PowerPC 8 is not yet supported.

##Development

Expand Down
9 changes: 1 addition & 8 deletions manifests/osfamily/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@
$_sslclientcert_path = "${_ssl_dir}/certs/${::clientcert}.pem"
$_sslclientkey_path = "${_ssl_dir}/private_keys/${::clientcert}.pem"

# Treat Amazon Linux just like Enterprise Linux 6
if $::operatingsystem == 'Amazon' {
$_repo_dir = "el-6-${::architecture}"
}
else {
$_repo_dir = $::platform_tag
}
$pe_server_version = pe_build_version()
$source = "${::puppet_agent::source}/${pe_server_version}/${_repo_dir}"
$source = "${::puppet_agent::source}/${pe_server_version}/${::puppet_agent::params::pe_repo_dir}"

# Due to the file paths changing on the PE Master, the 3.8 repository is no longer valid.
# On upgrade, remove the repo file so that a dangling reference is not left behind returning
Expand Down
8 changes: 7 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

case $::osfamily {
'RedHat', 'Amazon', 'Debian', 'Suse', 'Solaris', 'Darwin', 'AIX': {
'RedHat', 'Debian', 'Suse', 'Solaris', 'Darwin', 'AIX': {
$package_name = 'puppet-agent'
$service_names = ['puppet', 'mcollective']

Expand Down Expand Up @@ -67,6 +67,12 @@
}
}

# Treat Amazon Linux just like Enterprise Linux 6
$pe_repo_dir = ($::operatingsystem == 'Amazon') ? {
true => "el-6-${::architecture}",
default => $::platform_tag,
}

# The aio puppet-agent version currently installed on the compiling master
# (only used in PE)
$master_agent_version = $_is_pe ? {
Expand Down
65 changes: 34 additions & 31 deletions spec/classes/puppet_agent_osfamily_redhat_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
require 'spec_helper'

describe 'puppet_agent', :unless => Puppet.version < "3.8.0" || Puppet.version >= "4.0.0" do
[['Fedora', 'fedora/f$releasever'], ['CentOS', 'el/$releasever']].each do |os, urlbit|
[['Fedora', 'fedora/f$releasever'], ['CentOS', 'el/$releasever'], ['Amazon', 'el/$releasever']].each do |os, urlbit|
context "with #{os} and #{urlbit}" do
facts = {
let(:facts) {{
:osfamily => 'RedHat',
:operatingsystem => os,
:architecture => 'x64',
:servername => 'master.example.vm',
:clientcert => 'foo.example.vm',
}

let(:facts) { facts }
}}

it { is_expected.to contain_exec('import-RPM-GPG-KEY-puppetlabs').with({
'path' => '/bin:/usr/bin:/sbin:/usr/sbin',
Expand Down Expand Up @@ -44,39 +42,44 @@
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs',
}) }
end
end
end

context 'when PE' do
before(:each) do
# Need to mock the PE functions
[['RedHat', 'el-7-x86_64', 'el-7-x86_64'], ['Amazon', '', 'el-6-x64']].each do |os, tag, repodir|
context "when PE on #{os}" do
before(:each) do
# Need to mock the PE functions

Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args|
'4.0.0'
end
Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args|
'4.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args|
'1.2.5'
end
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args|
'1.2.5'
end
end

let(:facts) {
facts.merge({
:is_pe => true,
:platform_tag => 'el-7-x86_64',
})
}
let(:facts) {{
:osfamily => 'RedHat',
:operatingsystem => os,
:architecture => 'x64',
:servername => 'master.example.vm',
:clientcert => 'foo.example.vm',
:is_pe => true,
:platform_tag => tag,
}}

it { is_expected.to contain_yumrepo('puppetlabs-pepackages').with_ensure('absent') }
it { is_expected.to contain_yumrepo('puppetlabs-pepackages').with_ensure('absent') }

it { is_expected.to contain_yumrepo('pc1_repo').with({
'baseurl' => "https://master.example.vm:8140/packages/4.0.0/el-7-x86_64",
'enabled' => 'true',
'gpgcheck' => '1',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs',
'sslcacert' => '/etc/puppetlabs/puppet/ssl/certs/ca.pem',
'sslclientcert' => '/etc/puppetlabs/puppet/ssl/certs/foo.example.vm.pem',
'sslclientkey' => '/etc/puppetlabs/puppet/ssl/private_keys/foo.example.vm.pem',
}) }
end
it { is_expected.to contain_yumrepo('pc1_repo').with({
'baseurl' => "https://master.example.vm:8140/packages/4.0.0/#{repodir}",
'enabled' => 'true',
'gpgcheck' => '1',
'gpgkey' => 'file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs',
'sslcacert' => '/etc/puppetlabs/puppet/ssl/certs/ca.pem',
'sslclientcert' => '/etc/puppetlabs/puppet/ssl/certs/foo.example.vm.pem',
'sslclientkey' => '/etc/puppetlabs/puppet/ssl/private_keys/foo.example.vm.pem',
}) }
end
end
end

0 comments on commit 9e1796b

Please sign in to comment.