diff --git a/.fixtures.yml b/.fixtures.yml index 54f04bfba..d9f1b59b9 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,5 +2,6 @@ fixtures: repositories: stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" inifile: "https://github.com/puppetlabs/puppetlabs-inifile.git" + apt: "https://github.com/puppetlabs/puppetlabs-apt.git" symlinks: puppet_agent: "#{source_dir}" diff --git a/manifests/osfamily/debian.pp b/manifests/osfamily/debian.pp new file mode 100644 index 000000000..3315feb6a --- /dev/null +++ b/manifests/osfamily/debian.pp @@ -0,0 +1,12 @@ +class puppet_agent::osfamily::debian { + include apt + + apt::source { 'pc1_repo': + location => 'http://apt.puppetlabs.com', + repos => 'PC1', + key => { + 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + 'server' => 'pgp.mit.edu', + } + } +} diff --git a/manifests/params.pp b/manifests/params.pp index d31af4e6b..e72d19115 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,8 +5,8 @@ # class puppet_agent::params { case $::osfamily { - # TODO: Add Debian, Windows - 'RedHat', 'Amazon': { + # TODO: Windows + 'RedHat', 'Amazon', 'Debian': { $package_name = 'puppet-agent' $service_names = ['puppet', 'mcollective'] diff --git a/metadata.json b/metadata.json index 9b0a930a7..3fccf8a4c 100644 --- a/metadata.json +++ b/metadata.json @@ -23,10 +23,26 @@ "6", "7" ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "12.04", + "14.04", + "14.10" + ] } ], "dependencies": [ {"name":"puppetlabs-stdlib","version_requirement":">= 4.6.0"}, - {"name":"puppetlabs-inifile","version_requirement":">= 1.2.0"} + {"name":"puppetlabs-inifile","version_requirement":">= 1.2.0"}, + {"name":"puppetlabs-apt","version_requirement":">= 2.0.1"} ] } diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 6b329163a..f4957be68 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -61,12 +61,10 @@ class { 'puppet_agent': service_names => [] } end describe service('puppet') do - it { is_expected.to_not be_enabled } it { is_expected.to_not be_running } end describe service('mcollective') do - it { is_expected.to_not be_enabled } it { is_expected.to_not be_running } end end diff --git a/spec/acceptance/nodesets/debian-6-x64.yml b/spec/acceptance/nodesets/debian-6-x64.yml index 60a01c965..5a035648c 100644 --- a/spec/acceptance/nodesets/debian-6-x64.yml +++ b/spec/acceptance/nodesets/debian-6-x64.yml @@ -13,8 +13,8 @@ HOSTS: - agent - default platform: debian-6-amd64 - box: puppetlabs/debian-6.0.9-64-nocm - box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-6.0.9-64-nocm + box: puppetlabs/debian-6.0.10-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-6.0.10-64-nocm hypervisor: vagrant CONFIG: diff --git a/spec/acceptance/nodesets/debian-7-x64.yml b/spec/acceptance/nodesets/debian-7-x64.yml index 331b78903..05b957bbf 100644 --- a/spec/acceptance/nodesets/debian-7-x64.yml +++ b/spec/acceptance/nodesets/debian-7-x64.yml @@ -13,8 +13,8 @@ HOSTS: - agent - default platform: debian-7-amd64 - box: puppetlabs/debian-7.6-64-nocm - box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-7.6-64-nocm + box: puppetlabs/debian-7.8-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-7.8-64-nocm hypervisor: vagrant CONFIG: diff --git a/spec/classes/puppet_agent_osfamily_debian_spec.rb b/spec/classes/puppet_agent_osfamily_debian_spec.rb new file mode 100644 index 000000000..f7876a1be --- /dev/null +++ b/spec/classes/puppet_agent_osfamily_debian_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe 'puppet_agent::osfamily::debian' do + let(:facts) {{ + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :lsbdistcodename => 'wheezy', + :operatingsystem => 'Debian', + :architecture => 'foo', + }} + + it { is_expected.to contain_class('apt') } + + it { is_expected.to contain_apt__source('pc1_repo').with({ + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'PC1', + 'key' => { + 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', + 'server' => 'pgp.mit.edu', + }, + }) } +end diff --git a/spec/classes/puppet_agent_prepare_spec.rb b/spec/classes/puppet_agent_prepare_spec.rb index 2c33db49c..5ed4a0cc2 100644 --- a/spec/classes/puppet_agent_prepare_spec.rb +++ b/spec/classes/puppet_agent_prepare_spec.rb @@ -1,169 +1,174 @@ require 'spec_helper' -base_facts = { - :osfamily => 'RedHat', - :puppet_ssldir => '/dev/null/ssl', - :puppet_config => '/dev/null/puppet.conf', - :mco_server_config => nil, - :mco_client_config => nil, -} - MCO_CFG = {:server => '/etc/puppetlabs/mcollective/server.cfg', :client => '/etc/puppetlabs/mcollective/client.cfg'} MCO_LIBDIR = '/opt/puppetlabs/mcollective/plugins' MCO_PLUGIN_YAML = '/etc/puppetlabs/mcollective/facts.yaml' MCO_LOGFILE = '/var/log/puppetlabs/mcollective.log' describe 'puppet_agent::prepare' do - context 'on RedHat' do - let(:facts) { base_facts } + context 'supported operating systems' do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :puppet_ssldir => '/dev/null/ssl', + :puppet_config => '/dev/null/puppet.conf', + :mco_server_config => nil, + :mco_client_config => nil, + }) + end - [ - MCO_CFG, - {:server => '/etc/mcollective/server.cfg'}, - {:client => '/etc/mcollective/client.cfg'} - ].each do |mco_config| - [ - {'libdir' => 'libdir', 'plugin.yaml' => 'plugins'}, - {'libdir' => "libdir:#{MCO_LIBDIR}", 'plugin.yaml' => "plugins:#{MCO_PLUGIN_YAML}"}, - {'libdir' => nil, 'plugin.yaml' => nil}, - nil - ].each do |mco_settings| - context "with mco_config = #{mco_config} and mco_settings = #{mco_settings}" do - let(:facts) { - base_facts.merge( { - :mco_server_config => mco_config[:server], - :mco_client_config => mco_config[:client], - :mco_server_settings => mco_settings, - :mco_client_settings => mco_settings, - }) - } + [ + MCO_CFG, + {:server => '/etc/mcollective/server.cfg'}, + {:client => '/etc/mcollective/client.cfg'} + ].each do |mco_config| + [ + {'libdir' => 'libdir', 'plugin.yaml' => 'plugins'}, + {'libdir' => "libdir:#{MCO_LIBDIR}", 'plugin.yaml' => "plugins:#{MCO_PLUGIN_YAML}"}, + {'libdir' => nil, 'plugin.yaml' => nil}, + nil + ].each do |mco_settings| + context "with mco_config = #{mco_config} and mco_settings = #{mco_settings}" do + let(:facts) { + facts.merge( { + :puppet_ssldir => '/dev/null/ssl', + :puppet_config => '/dev/null/puppet.conf', + :mco_server_config => mco_config[:server], + :mco_client_config => mco_config[:client], + :mco_server_settings => mco_settings, + :mco_client_settings => mco_settings, + }) + } - it { is_expected.to contain_file('/etc/puppetlabs/mcollective').with_ensure('directory') } + it { is_expected.to contain_file('/etc/puppetlabs/mcollective').with_ensure('directory') } - mco_config.each do |node, cfg| - if cfg - it { is_expected.to contain_file(MCO_CFG[node]).with({ - 'ensure' => 'file', - 'source' => cfg, - }) } + mco_config.each do |node, cfg| + if cfg + it { is_expected.to contain_file(MCO_CFG[node]).with({ + 'ensure' => 'file', + 'source' => cfg, + }) } - if mco_settings && mco_settings['libdir'] && !mco_settings['libdir'].include?(MCO_LIBDIR) - it { is_expected.to contain_ini_setting("#{node}/libdir").with({ - 'section' => '', - 'setting' => 'libdir', - 'path' => MCO_CFG[node], - 'value' => "#{MCO_LIBDIR}:#{mco_settings['libdir']}", - }).that_requires("File[#{MCO_CFG[node]}]") } - else - it { is_expected.to_not contain_ini_setting("#{node}/libdir") } - end + if mco_settings && mco_settings['libdir'] && !mco_settings['libdir'].include?(MCO_LIBDIR) + it { is_expected.to contain_ini_setting("#{node}/libdir").with({ + 'section' => '', + 'setting' => 'libdir', + 'path' => MCO_CFG[node], + 'value' => "#{MCO_LIBDIR}:#{mco_settings['libdir']}", + }).that_requires("File[#{MCO_CFG[node]}]") } + else + it { is_expected.to_not contain_ini_setting("#{node}/libdir") } + end - if mco_settings && mco_settings['plugin.yaml'] && !mco_settings['plugin.yaml'].include?(MCO_PLUGIN_YAML) - it { is_expected.to contain_ini_setting("#{node}/plugin.yaml").with({ - 'section' => '', - 'setting' => 'plugin.yaml', - 'path' => MCO_CFG[node], - 'value' => "#{mco_settings['plugin.yaml']}:#{MCO_PLUGIN_YAML}", - }).that_requires("File[#{MCO_CFG[node]}]") } - else - it { is_expected.to_not contain_ini_setting("#{node}/plugin.yaml") } - end + if mco_settings && mco_settings['plugin.yaml'] && !mco_settings['plugin.yaml'].include?(MCO_PLUGIN_YAML) + it { is_expected.to contain_ini_setting("#{node}/plugin.yaml").with({ + 'section' => '', + 'setting' => 'plugin.yaml', + 'path' => MCO_CFG[node], + 'value' => "#{mco_settings['plugin.yaml']}:#{MCO_PLUGIN_YAML}", + }).that_requires("File[#{MCO_CFG[node]}]") } + else + it { is_expected.to_not contain_ini_setting("#{node}/plugin.yaml") } + end - it { is_expected.to contain_ini_setting("#{node}/logfile").with({ - 'section' => '', - 'setting' => 'logfile', - 'path' => MCO_CFG[node], - 'value' => MCO_LOGFILE, - }).that_requires("File[#{MCO_CFG[node]}]") } - else - it { is_expected.to_not contain_file(MCO_CFG[node]) } + it { is_expected.to contain_ini_setting("#{node}/logfile").with({ + 'section' => '', + 'setting' => 'logfile', + 'path' => MCO_CFG[node], + 'value' => MCO_LOGFILE, + }).that_requires("File[#{MCO_CFG[node]}]") } + else + it { is_expected.to_not contain_file(MCO_CFG[node]) } + end + end end end end - end - end - ['/etc/puppetlabs', '/etc/puppetlabs/puppet'].each do |dir| - it { is_expected.to contain_file(dir).with_ensure('directory') } - end + ['/etc/puppetlabs', '/etc/puppetlabs/puppet'].each do |dir| + it { is_expected.to contain_file(dir).with_ensure('directory') } + end - it { is_expected.to contain_file('/etc/puppetlabs/puppet/puppet.conf').with({ - 'ensure' => 'file', - 'source' => '/dev/null/puppet.conf', - }) } + it { is_expected.to contain_file('/etc/puppetlabs/puppet/puppet.conf').with({ + 'ensure' => 'file', + 'source' => '/dev/null/puppet.conf', + }) } - it { is_expected.to contain_file('/etc/puppetlabs/puppet/ssl').with({ - 'ensure' => 'directory', - 'source' => '/dev/null/ssl', - 'backup' => 'false', - 'recurse' => 'true', - }) } + it { is_expected.to contain_file('/etc/puppetlabs/puppet/ssl').with({ + 'ensure' => 'directory', + 'source' => '/dev/null/ssl', + 'backup' => 'false', + 'recurse' => 'true', + }) } - ['agent', 'main', 'master'].each do |section| - ['allow_variables_with_dashes', - 'async_storeconfigs', - 'binder', - 'catalog_format', - 'certdnsnames', - 'certificate_expire_warning', - 'couchdb_url', - 'dbadapter', - 'dbconnections', - 'dblocation', - 'dbmigrate', - 'dbname', - 'dbpassword', - 'dbport', - 'dbserver', - 'dbsocket', - 'dbuser', - 'dynamicfacts', - 'http_compression', - 'httplog', - 'ignoreimport', - 'immutable_node_data', - 'inventory_port', - 'inventory_server', - 'inventory_terminus', - 'legacy_query_parameter_serialization', - 'listen', - 'localconfig', - 'manifestdir', - 'masterlog', - 'parser', - 'preview_outputdir', - 'puppetport', - 'queue_source', - 'queue_type', - 'rails_loglevel', - 'railslog', - 'report_serialization_format', - 'reportfrom', - 'rrddir', - 'rrdinterval', - 'sendmail', - 'smtphelo', - 'smtpport', - 'smtpserver', - 'ssldir', - 'stringify_facts', - 'tagmap', - 'templatedir', - 'thin_storeconfigs', - 'trusted_node_data', - 'zlib', - 'config_version', - 'manifest', - 'modulepath', - 'disable_warnings', - 'vardir', - 'rundir', - 'libdir', - 'confdir'].each do |setting| - it { is_expected.to contain_ini_setting("#{section}/#{setting}").with_ensure('absent') } - end - end + ['agent', 'main', 'master'].each do |section| + ['allow_variables_with_dashes', + 'async_storeconfigs', + 'binder', + 'catalog_format', + 'certdnsnames', + 'certificate_expire_warning', + 'couchdb_url', + 'dbadapter', + 'dbconnections', + 'dblocation', + 'dbmigrate', + 'dbname', + 'dbpassword', + 'dbport', + 'dbserver', + 'dbsocket', + 'dbuser', + 'dynamicfacts', + 'http_compression', + 'httplog', + 'ignoreimport', + 'immutable_node_data', + 'inventory_port', + 'inventory_server', + 'inventory_terminus', + 'legacy_query_parameter_serialization', + 'listen', + 'localconfig', + 'manifestdir', + 'masterlog', + 'parser', + 'preview_outputdir', + 'puppetport', + 'queue_source', + 'queue_type', + 'rails_loglevel', + 'railslog', + 'report_serialization_format', + 'reportfrom', + 'rrddir', + 'rrdinterval', + 'sendmail', + 'smtphelo', + 'smtpport', + 'smtpserver', + 'ssldir', + 'stringify_facts', + 'tagmap', + 'templatedir', + 'thin_storeconfigs', + 'trusted_node_data', + 'zlib', + 'config_version', + 'manifest', + 'modulepath', + 'disable_warnings', + 'vardir', + 'rundir', + 'libdir', + 'confdir'].each do |setting| + it { is_expected.to contain_ini_setting("#{section}/#{setting}").with_ensure('absent') } + end + end - it { is_expected.to contain_class('puppet_agent::osfamily::redhat') } + it { is_expected.to contain_class("puppet_agent::osfamily::#{facts[:osfamily]}") } + end + end end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index ac79c4620..fcc5e64ae 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -48,6 +48,7 @@ def activemq_host puppet_module_install_on(master, :source => PROJ_ROOT, :module_name => 'puppet_agent') on master, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } on master, puppet('module', 'install', 'puppetlabs-inifile'), { :acceptable_exit_codes => [0,1] } + on master, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0,1] } # Install activemq on master install_package master, 'activemq' @@ -153,6 +154,7 @@ def setup_puppet_on(host, opts = {}) puppet_module_install_on(host, :source => PROJ_ROOT, :module_name => 'puppet_agent') on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } on host, puppet('module', 'install', 'puppetlabs-inifile'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0,1] } end end @@ -163,7 +165,18 @@ def teardown_puppet_on(host) pp = <<-EOS package { ['puppet-agent', 'puppet', 'mcollective', 'mcollective-client']: ensure => purged } file { ['/etc/puppet', '/etc/puppetlabs', '/etc/mcollective']: ensure => absent, force => true, backup => false } -yumrepo { 'pc1_repo': ensure => absent } +#{ + case host['platform'] + when /debian|ubuntu/ + on host, '/opt/puppetlabs/bin/puppet module install puppetlabs-apt', { :acceptable_exit_codes => [0,1] } + "include apt\napt::source { 'pc1_repo': ensure => absent }" + when /fedora|el|centos/ + "yumrepo { 'pc1_repo': ensure => absent }" + else + logger.notify("Not sure how to remove repos on #{host['platform']}") + '' + end +} EOS on host, "/opt/puppetlabs/bin/puppet apply -e \"#{pp}\"" end