Skip to content

Commit

Permalink
Lots of fixes and testing updates.
Browse files Browse the repository at this point in the history
- Remove yum dependency since on some early versions of puppet it is missing
  repo_gpgcheck, which is really important to have enabled.
- Remove apt dependency as well. Fewer dependencies is usually better.
- Add testing support for CentOS 5.10, CentOS 7, Ubuntu 10.04, and Ubuntu
  14.04. These OSs are supported by packagecloud so we should be testing
  them.
- Fix manifests to deal with different package names on Trusty
- Tweak specs a bit to install gems to /usr/local/bin on all OSs to make
  testing and path issues much easier to deal with.
  • Loading branch information
ice799 committed Oct 14, 2014
1 parent 38b3af2 commit f53a9e7
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 48 deletions.
5 changes: 1 addition & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
# limitations under the License.
#

class packagecloud(
$gpgurl = "https://packagecloud.io/gpg.key",
$gpg_file_path = "/etc/pki/rpm-gpg/RPM-GPG-KEY-packagecloud",
) {
class packagecloud() {
case $::operatingsystem {
'debian', 'ubuntu': {
package { 'apt-transport-https':
Expand Down
65 changes: 42 additions & 23 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$type = undef,
$fq_name = undef,
$master_token = undef,
$gpg_url = "https://packagecloud.io/gpg.key",
$priority = undef,
) {
validate_string($type)
validate_string($master_token)
Expand Down Expand Up @@ -57,14 +57,25 @@
case $osname {
'debian', 'ubuntu': {

include apt
$component = 'main'
$repo_url = "${base_url}/${repo_name}/${osname}"
$distribution = $::lsbdistcodename

apt::source { "${normalized_name}":
location => "${base_url}/${repo_name}/$osname",
repos => 'main',
key => 'D59097AB',
key_server => 'pgp.mit.edu',
include_src => true,
file { "${normalized_name}":
path => "/etc/apt/sources.list.d/${normalized_name}.list",
ensure => file,
mode => 0644,
content => template('packagecloud/apt.erb'),
}

exec { "apt_key_add_${normalized_name}":
command => "wget -qO - https://packagecloud.io/gpg.key | apt-key add -",
require => File["${normalized_name}"],
}

exec { "apt_get_update_${normalized_name}":
command => "apt-get update -o Dir::Etc::sourcelist=\"sources.list.d/${normalized_name}.list\" -o Dir::Etc::sourceparts=\"-\" -o APT::Get::List-Cleanup=\"0\"",
require => Exec["apt_key_add_${normalized_name}"],
}
}

Expand Down Expand Up @@ -95,26 +106,34 @@
}
}

yumrepo { "${normalized_name}":
ensure => present,
descr => "${normalized_name}",
enabled => 1,
baseurl => $::operatingsystem ? {
/(RedHat|redhat|CentOS|centos|Scientific)/ => $yum_repo_url,
'Fedora' => "${base_url}/${repo_name}/fedora/$::operatingsystemmajrelease/$::architecture/",
'Amazon' => "${base_url}/${repo_name}/el/6/$::architecture",
},
gpgcheck => 0,
gpgkey => $gpg_url,
sslverify => 1,
sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
repo_gpgcheck => $repo_gpgcheck,
$description = $normalized_name
$repo_url = $::operatingsystem ? {
/(RedHat|redhat|CentOS|centos|Scientific)/ => $yum_repo_url,
'Fedora' => "${base_url}/${repo_name}/fedora/$::operatingsystemmajrelease/$::architecture/",
'Amazon' => "${base_url}/${repo_name}/el/6/$::architecture",
}

$gpg_url = "https://packagecloud.io/gpg.key"
$gpg_file_path = "/etc/pki/rpm-gpg/RPM-GPG-KEY-packagecloud"

exec { "import_gpg_${normalized_name}":
command => "wget -qO ${gpg_file_path} ${gpg_url}",
path => "/usr/bin",
creates => $gpg_file_path,
}

file { "${normalized_name}":
path => "/etc/yum.repos.d/${normalized_name}.repo",
ensure => file,
mode => 0644,
content => template('packagecloud/yum.erb'),
require => Exec["import_gpg_${normalized_name}"],
}

exec { "yum_make_cache_${repo_name}":
command => "yum -q makecache -y --disablerepo='*' --enablerepo='${normalized_name}'",
path => "/usr/bin",
require => Yumrepo["${normalized_name}"],
require => File["${normalized_name}"],
}
}

Expand Down
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
{
"version_range": ">= 1.0.0",
"name": "puppetlabs-stdlib"
},
{
"version_range": ">= 1.4.2",
"name": "puppetlabs-apt"
}
]
}
2 changes: 2 additions & 0 deletions templates/apt.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb <%= @repo_url %> <%= @distribution %> <%= @component %>
deb-src <%= @repo_url %> <%= @distribution %> <%= @component %>
12 changes: 12 additions & 0 deletions templates/yum.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[<%= @normalized_name %>]
name=<%= @description %>
baseurl=<%= @repo_url %>
repo_gpgcheck=<%= @repo_gpgcheck %>
<% if @priority -%>
priority=<%=@priority %>
<% end -%>
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-packagecloud
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
30 changes: 29 additions & 1 deletion test/.kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,46 @@ provisioner:
hiera_data_path: test/hieradata

platforms:
- name: nocm_ubuntu-10.04
driver_plugin: vagrant
driver_config:
box: nocm_ubuntu-10.04
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box

- name: nocm_ubuntu-12.04
driver_plugin: vagrant
driver_config:
box: nocm_ubuntu-12.04
box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box

- name: ubuntu-14.04
driver_plugin: vagrant
driver_config:
box: opscode-ubuntu-14.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-14.04_provisionerless.box

- name: centos-5.10
provisioner:
puppet_yum_repo: http://yum.puppetlabs.com/puppetlabs-release-el-5.noarch.rpm
driver_plugin: vagrant
driver_config:
box: nocm_centos-5.10
box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-510-x64-virtualbox-nocm.box

- name: centos-6.5
driver_plugin: vagrant
driver_config:
box: nocm_centos-6.5
box_url: http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box

- name: centos-7.0
provisioner:
puppet_yum_repo: https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm
driver_plugin: vagrant
driver_config:
box: opscode-centos-7.0
box_url: http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.0_chef-provisionerless.box

suites:
- name: default
manifest: site.pp
suite_path: integration
2 changes: 1 addition & 1 deletion test/.librarian/puppet/config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
LIBRARIAN_PUPPET_DESTRUCTIVE: "false"
LIBRARIAN_PUPPET_PATH: /var/folders/w7/pky26x5n4rj3jlb5cq3s38lh0000gn/T/default-centos-65-sandbox-20141013-75665-1k1s3fm/modules
LIBRARIAN_PUPPET_PATH: /var/folders/w7/pky26x5n4rj3jlb5cq3s38lh0000gn/T/default-centos-70-sandbox-20141014-88421-183zuav/modules
2 changes: 1 addition & 1 deletion test/test/integration/default/serverspec/jakedotrb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

path = os[:family].downcase == "ubuntu" ? "/usr/local/bin/jakedotrb" : "/usr/bin/jakedotrb"
path = "/usr/local/bin/jakedotrb"

describe command("ls #{path}") do
its(:exit_status) { should eq 0 }
Expand Down
56 changes: 42 additions & 14 deletions test/test/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
Exec {
path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ]
}

package { 'rubygems':
name => 'rubygems',
ensure => present,
path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/", "/usr/local/bin" ]
}

case $operatingsystem {
'RedHat', 'CentOS': {
package { 'rubygems':
name => 'rubygems',
ensure => present,
}

case $::operatingsystemrelease {
/^5.*/: {
package { 'epel5':
source => 'http://mirror.vcu.edu/pub/gnu_linux/epel/5/i386/epel-release-5-4.noarch.rpm',
ensure => present,
}
}
}

packagecloud::repo { "computology/packagecloud-cookbook-test-public":
fq_name => "computology/packagecloud-cookbook-test-public",
type => 'rpm',
Expand All @@ -25,6 +34,28 @@
}
}
/^(Debian|Ubuntu)$/:{
case $lsbdistcodename {
'trusty': {
package { 'dpkg-dev':
name => 'dpkg-dev',
ensure => present,
}
package { 'rubygems':
name => 'rubygems-integration',
ensure => present,
}
}
default: {
package { 'rubygems':
name => 'rubygems',
ensure => present,
}
package { 'libgemplugin-ruby':
ensure => present,
}
}
}

packagecloud::repo { "computology/packagecloud-cookbook-test-public":
fq_name => "computology/packagecloud-cookbook-test-public",
type => 'deb',
Expand All @@ -45,10 +76,6 @@
cwd => '/home/vagrant',
require => Packagecloud::Repo["computology/packagecloud-cookbook-test-public"],
}

package { 'libgemplugin-ruby':
ensure => present,
}
}
}

Expand All @@ -64,8 +91,9 @@
}

package { 'jake gem':
name => 'jakedotrb',
ensure => 'installed',
provider => 'gem',
require => Package['rubygems'],
name => 'jakedotrb',
ensure => 'installed',
provider => 'gem',
install_options => ['--bindir', '/usr/local/bin'],
require => Package['rubygems'],
}

0 comments on commit f53a9e7

Please sign in to comment.