diff --git a/CHANGELOG.md b/CHANGELOG.md index 372afa1..d56fec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,57 +1,61 @@ +## Release 7.0.0 +- Default to Elastic Stack version 7 +- Drop support for Puppet version < 4.10.0 + ## Release 6.3.2 - Allow puppetlabs-apt version 7.x - Allow puppetlabs-stdlib version 6.x - Allow puppet-yum version 4.x - Constrain puppetlabs-yumrepo_core to puppet 6+ ## Release 6.3.1 - Remove extraneous files from module package ## Release 6.3.0 [Deleted from Forge] - Support Puppet 6 ## Release 6.2.4 - Allow puppetlabs-apt version 6.x ## Release 6.2.3 - Allow puppetlabs-yum version 3.x ## Release 6.2.2 - Allow puppetlabs-stdlib version 5.x ## Release 6.2.1 - Allow puppetlabs-apt version 5.x ## Release 6.2.0 - Add base_repo_url param ## Release 6.1.0 - Support OSS-only package repositories ## Release 6.0.1 - Remove aggressive ordering causing all packages to come after apt::update ## Release 6.0.0 Version number increase to indicate that this module is considered of reasonable quality and is used by version 6.0.0 of elastic/logstash. - Changed default repository to version to 6 ## Release 0.2.1 - Remove some resource defaults that were causing problems on Puppet 5 ## Release 0.2.0 - Expand declared OS support - Relax minimum Puppet version to 4.6.1 - Support pre-release artifacts diff --git a/manifests/repo.pp b/manifests/repo.pp index 60fa6d3..774291c 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -1,144 +1,144 @@ # elastic_stack::repo # # @summary Set up the package repository for Elastic Stack components # # @example # include elastic_stack::repo # # @param oss Whether to use the purely open source (i.e., bundled without X-Pack) repository # @param prerelease Whether to use a repo for prerelease versions, like "6.0.0-rc2" # @param priority A numeric priority for the repo, passed to the package management system # @param proxy The URL of a HTTP proxy to use for package downloads (YUM only) # @param version The (major) version of the Elastic Stack for which to configure the repo # @param base_repo_url The base url for the repo path class elastic_stack::repo ( Boolean $oss = false, Boolean $prerelease = false, Optional[Integer] $priority = undef, String $proxy = 'absent', - Integer $version = 6, + Integer $version = 7, Optional[String] $base_repo_url = undef, ) { if $prerelease { $version_suffix = '.x-prerelease' } else { $version_suffix = '.x' } if $oss { $version_prefix = 'oss-' } else { $version_prefix = '' } if $version > 2 { $_repo_url = $base_repo_url ? { undef => 'https://artifacts.elastic.co/packages', default => $base_repo_url, } case $facts['os']['family'] { 'Debian': { $_repo_path = 'apt' } default: { $_repo_path = 'yum' } } } else { $_repo_url = $base_repo_url ? { undef => 'https://packages.elastic.co/elasticsearch', default => $base_repo_url, } case $facts['os']['family'] { 'Debian': { $_repo_path = 'debian' } default: { $_repo_path = 'centos' } } } $base_url = "${_repo_url}/${version_prefix}${version}${version_suffix}/${_repo_path}" $key_id='46095ACC8548582C1A2699A9D27D666CD88E42B4' $key_source='https://artifacts.elastic.co/GPG-KEY-elasticsearch' $description='Elastic package repository.' case $::osfamily { 'Debian': { include apt apt::source { 'elastic': ensure => 'present', comment => $description, location => $base_url, release => 'stable', repos => 'main', key => { 'id' => $key_id, 'source' => $key_source, }, include => { 'deb' => true, 'src' => false, }, pin => $priority, } } 'RedHat', 'Linux': { yumrepo { 'elastic': descr => $description, baseurl => $base_url, gpgcheck => 1, gpgkey => $key_source, enabled => 1, proxy => $proxy, priority => $priority, } ~> exec { 'elastic_yumrepo_yum_clean': command => 'yum clean metadata expire-cache --disablerepo="*" --enablerepo="elastic"', refreshonly => true, returns => [0, 1], path => [ '/bin', '/usr/bin', '/usr/local/bin' ], cwd => '/', } } 'Suse': { # Older versions of SLES do not ship with rpmkeys if $::operatingsystem == 'SLES' and versioncmp($::operatingsystemmajrelease, '11') <= 0 { $_import_cmd = "rpm --import ${key_source}" } else { $_import_cmd = "rpmkeys --import ${key_source}" } exec { 'elastic_suse_import_gpg': command => $_import_cmd, unless => "test $(rpm -qa gpg-pubkey | grep -i 'D88E42B4' | wc -l) -eq 1", notify => Zypprepo['elastic'], path => [ '/bin', '/usr/bin', '/usr/local/bin' ], cwd => '/', } zypprepo { 'elastic': baseurl => $base_url, enabled => 1, autorefresh => 1, name => 'elastic', gpgcheck => 1, gpgkey => $key_source, type => 'yum', priority => $priority, } ~> exec { 'elastic_zypper_refresh_elastic': command => 'zypper refresh elastic', refreshonly => true, path => [ '/bin', '/usr/bin', '/usr/local/bin' ], cwd => '/', } } default: { fail("\"${module_name}\" provides no repository information for OSfamily \"${::osfamily}\"") } } } diff --git a/metadata.json b/metadata.json index de1aebf..ec7d793 100644 --- a/metadata.json +++ b/metadata.json @@ -1,74 +1,74 @@ { "name": "elastic-elastic_stack", - "version": "6.3.2", + "version": "7.0.0", "author": "toby@jarpy.net", "summary": "Helpers for installing and configuring components of the Elastic Stack.", "license": "Apache-2.0", "source": "https://github.com/elastic/puppet-elastic-stack", "project_page": "https://github.com/elastic/puppet-elastic-stack", "issues_url": "https://github.com/elastic/puppet-elastic-stack/issues", "dependencies": [ { "name": "puppetlabs-stdlib", "version_requirement": ">= 4.13.1 < 7.0.0" }, { "name": "puppetlabs/apt", "version_requirement": ">= 2.0.0 < 8.0.0" }, { "name": "puppet/yum", "version_requirement": ">= 0.9.6 < 5.0.0" }, { "name": "puppetlabs/yumrepo_core", "version_requirement": ">= 1.0.0 < 2.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "7", "8", "9" ] }, { "operatingsystem": "OpenSuSE", "operatingsystemrelease": [ "42.2" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6.0", "7.0" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "12.1", "12.2" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04", "16.04" ] } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 4.6.1 < 7.0.0" + "version_requirement": ">= 4.10.0 < 7.0.0" } ], "pdk-version": "1.0.1", "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-module-template.git", "template-ref": "heads/master-0-g5db7961" } diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 9a86310..409c4fd 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -1,145 +1,158 @@ require 'spec_helper' def url(format, version) case version when %r{^2} repo_type = (format == 'yum') ? 'centos' : 'debian' "https://packages.elastic.co/elasticsearch/#{version}/#{repo_type}" else "https://artifacts.elastic.co/packages/#{version}/#{format}" end end -def declare_apt(version: '6.x', **params) +def declare_apt(version: '7.x', **params) params[:location] ||= url('apt', version) contain_apt__source('elastic').with(params) end -def declare_yum(version: '6.x', **params) +def declare_yum(version: '7.x', **params) params[:baseurl] ||= url('yum', version) contain_yumrepo('elastic').with(params) end -def declare_zypper(version: '6.x', **params) +def declare_zypper(version: '7.x', **params) params[:baseurl] ||= url('yum', version) contain_zypprepo('elastic').with(params) end describe 'elastic_stack::repo', type: 'class' do default_params = {} rpm_key_cmd = 'rpmkeys --import https://artifacts.elastic.co/GPG-KEY-elasticsearch' on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) { facts } case facts[:os]['family'] when 'Debian' it { is_expected.to declare_apt } when 'RedHat' it { is_expected.to declare_yum } when 'Suse' it { is_expected.to declare_zypper } it { is_expected.to contain_exec('elastic_suse_import_gpg').with(command: rpm_key_cmd) } it { is_expected.to contain_exec('elastic_zypper_refresh_elastic').with(command: 'zypper refresh elastic') } end context 'with "version => 2"' do let(:params) { default_params.merge(version: 2) } case facts[:os]['family'] when 'Debian' it { is_expected.to declare_apt(version: '2.x') } when 'RedHat' it { is_expected.to declare_yum(version: '2.x') } when 'Suse' it { is_expected.to declare_zypper(version: '2.x') } end end context 'with "version => 5"' do let(:params) { default_params.merge(version: 5) } case facts[:os]['family'] when 'Debian' it { is_expected.to declare_apt(version: '5.x') } when 'RedHat' it { is_expected.to declare_yum(version: '5.x') } when 'Suse' it { is_expected.to declare_zypper(version: '5.x') } end end + context 'with "version => 6"' do + let(:params) { default_params.merge(version: 6) } + + case facts[:os]['family'] + when 'Debian' + it { is_expected.to declare_apt(version: '6.x') } + when 'RedHat' + it { is_expected.to declare_yum(version: '6.x') } + when 'Suse' + it { is_expected.to declare_zypper(version: '6.x') } + end + end + context 'with "priority => 99"' do let(:params) { default_params.merge(priority: 99) } case facts[:os]['family'] when 'Debian' it { is_expected.to declare_apt(pin: 99) } when 'RedHat' it { is_expected.to declare_yum(priority: 99) } when 'Suse' it { is_expected.to declare_zypper(priority: 99) } end end context 'with "prerelease => true"' do let(:params) { default_params.merge(prerelease: true) } case facts[:os]['family'] when 'Debian' - it { is_expected.to declare_apt(version: '6.x-prerelease') } + it { is_expected.to declare_apt(version: '7.x-prerelease') } when 'RedHat' - it { is_expected.to declare_yum(version: '6.x-prerelease') } + it { is_expected.to declare_yum(version: '7.x-prerelease') } when 'Suse' - it { is_expected.to declare_zypper(version: '6.x-prerelease') } + it { is_expected.to declare_zypper(version: '7.x-prerelease') } end end context 'with "oss => true"' do let(:params) { default_params.merge(oss: true) } case facts[:os]['family'] when 'Debian' - it { is_expected.to declare_apt(version: 'oss-6.x') } + it { is_expected.to declare_apt(version: 'oss-7.x') } when 'RedHat' - it { is_expected.to declare_yum(version: 'oss-6.x') } + it { is_expected.to declare_yum(version: 'oss-7.x') } when 'Suse' - it { is_expected.to declare_zypper(version: 'oss-6.x') } + it { is_expected.to declare_zypper(version: 'oss-7.x') } end end context 'with "oss and prerelease => true"' do let(:params) { default_params.merge(oss: true, prerelease: true) } case facts[:os]['family'] when 'Debian' - it { is_expected.to declare_apt(version: 'oss-6.x-prerelease') } + it { is_expected.to declare_apt(version: 'oss-7.x-prerelease') } when 'RedHat' - it { is_expected.to declare_yum(version: 'oss-6.x-prerelease') } + it { is_expected.to declare_yum(version: 'oss-7.x-prerelease') } when 'Suse' - it { is_expected.to declare_zypper(version: 'oss-6.x-prerelease') } + it { is_expected.to declare_zypper(version: 'oss-7.x-prerelease') } end end context 'with base_repo_url parameter' do let(:params) { default_params.merge(base_repo_url: 'https://mymirror.example.org/elastic-artifacts/packages') } case facts[:os]['family'] when 'Debian' - it { is_expected.to declare_apt(location: 'https://mymirror.example.org/elastic-artifacts/packages/6.x/apt') } + it { is_expected.to declare_apt(location: 'https://mymirror.example.org/elastic-artifacts/packages/7.x/apt') } when 'RedHat' - it { is_expected.to declare_yum(baseurl: 'https://mymirror.example.org/elastic-artifacts/packages/6.x/yum') } + it { is_expected.to declare_yum(baseurl: 'https://mymirror.example.org/elastic-artifacts/packages/7.x/yum') } when 'Suse' - it { is_expected.to declare_zypper(baseurl: 'https://mymirror.example.org/elastic-artifacts/packages/6.x/yum') } + it { is_expected.to declare_zypper(baseurl: 'https://mymirror.example.org/elastic-artifacts/packages/7.x/yum') } end end context 'with proxy parameter' do let(:params) { default_params.merge(proxy: 'http://proxy.com:8080') } it { is_expected.to declare_yum(proxy: 'http://proxy.com:8080') } if facts[:os]['family'] == 'RedHat' end end end end