Skip to content

Commit

Permalink
Revert "Update .gitlab-ci.yml"
Browse files Browse the repository at this point in the history
This reverts commit 38b70e4c1794998d33e628aa68fccaeade93dc8a.
  • Loading branch information
dannygoulder committed Feb 15, 2021
1 parent f9323d8 commit ded9aa2
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/BracesAroundHashParameters:
Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0.
See https://github.com/rubocop-hq/rubocop/pull/7643
Enabled: true
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"jpogran.puppet-vscode",
"puppet.puppet-vscode",
"rebornix.Ruby"
]
}
13 changes: 6 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,35 @@ if Bundler.rubygems.find_name('github_changelog_generator').any?
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
config.add_pr_wo_labels = true
config.issues = false
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
config.configure_sections = {
"Changed" => {
"prefix" => "### Changed",
"labels" => ["backwards-incompatible"],
},
"Added" => {
"prefix" => "### Added",
"labels" => ["feature", "enhancement"],
"labels" => ["enhancement", "feature"],
},
"Fixed" => {
"prefix" => "### Fixed",
"labels" => ["bugfix"],
"labels" => ["bug", "documentation", "bugfix"],
},
}
end
else
desc 'Generate a Changelog from GitHub'
task :changelog do
raise <<EOM
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
The changelog tasks depends on recent features of the github_changelog_generator gem.
Please manually add it to your .sync.yml for now, and run `pdk update`:
---
Gemfile:
optional:
':development':
- gem: 'github_changelog_generator'
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
version: '~> 1.15'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
EOM
end
end
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
# from the target node. This is good for bulk uninstallation across a
# network. Valid values are 'present' or 'absent'. (default: 'present')
#
# * `extract_method`
# [Enum] Select which extraction method to use for the downloaded zip file.
# Only valid on Windows nodes.
# Valid values are `shell` or `archive`
#
# * `fields`
# Optional[Hash] Optional fields to add to each transaction to provide
# additonal information. (default: undef)
Expand Down Expand Up @@ -169,6 +174,7 @@
Boolean $disable_configtest = $metricbeat::params::disable_configtest,
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $download_url = $metricbeat::params::download_url,
Enum['present', 'absent'] $ensure = $metricbeat::params::ensure,
Enum['shell', 'archive'] $extract_method = $metricbeat::params::extract_method,
Optional[Hash] $fields = $metricbeat::params::fields,
Boolean $fields_under_root = $metricbeat::params::fields_under_root,
Optional[String] $install_dir = $metricbeat::params::install_dir,
Expand Down
54 changes: 34 additions & 20 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,48 @@
}
}

archive{ $zip_file:
source => $metricbeat::real_download_url,
cleanup => false,
creates => $version_file,
proxy_server => $metricbeat::proxy_address,
}
exec{"unzip ${filename}":
command => "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '${metricbeat::install_dir}')).Copyhere(\$sh.namespace((Convert-Path '${zip_file}')).items(), 16)", # lint:ignore:140chars
creates => $version_file,
require => [
File[$metricbeat::install_dir],
Archive[$zip_file],
],
}
if $metricbeat::extract_method == 'shell' {
archive { $zip_file:
source => $metricbeat::real_download_url,
cleanup => false,
creates => $version_file,
proxy_server => $metricbeat::proxy_address,
}

# Clean up after ourselves
file{$zip_file:
ensure => absent,
backup => false,
require => Exec["unzip ${filename}"],
exec{"unzip ${filename}":
command => "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path '${metricbeat::install_dir}')).Copyhere(\$sh.namespace((Convert-Path '${zip_file}')).items(), 16)", # lint:ignore:140chars
creates => $version_file,
require => [
File[$metricbeat::install_dir],
Archive[$zip_file],
],
}
# Clean up after ourselves
file{$zip_file:
ensure => absent,
backup => false,
require => Exec["unzip ${filename}"],
before => Exec["stop service ${filename}"],
}

} else {
archive { $zip_file:
source => $metricbeat::real_download_url,
cleanup => true,
extract => true,
extract_path => $metricbeat::install_dir,
creates => $version_file,
proxy_server => $metricbeat::proxy_address,
before => Exec["stop service ${filename}"],
}
}


# You can't remove the old dir while the service has files locked...
exec{"stop service ${filename}":
command => 'Set-Service -Name metricbeat -Status Stopped',
creates => $version_file,
onlyif => 'if(Get-WmiObject -Class Win32_Service -Filter "Name=\'metricbeat\'") {exit 0} else {exit 1}',
require => Exec["unzip ${filename}"],
}
exec{"rename ${filename}":
command => "Remove-Item '${install_folder}' -Recurse -Force -ErrorAction SilentlyContinue;Rename-Item '${metricbeat::install_dir}/${filename}' '${install_folder}'", # lint:ignore:140chars
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$config_mode = '0600'
$disable_configtest = false
$download_url = undef
$extract_method = 'shell'
$fields = undef
$fields_under_root = false
$manage_repo = true
Expand Down
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"logstash",
"elastic"
],
"pdk-version": "1.17.0",
"template-url": "pdk-default#1.17.0",
"template-ref": "tags/1.17.0-0-gd3a4319"
"pdk-version": "1.18.1",
"template-url": "pdk-default#1.18.1",
"template-ref": "tags/1.18.1-0-g3d2e75c"
}
16 changes: 11 additions & 5 deletions spec/classes/metricbeat_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'metricbeat' do
on_supported_os(facterversion: '2.4').each do |os, os_facts|
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

Expand Down Expand Up @@ -127,16 +127,22 @@

describe 'metricbeat::install' do
if os_facts[:kernel] == 'windows'
context 'with shell extractor' do
let(:params) { { 'extract_method' => 'shell' } }

it {
is_expected.to contain_exec('unzip metricbeat-6.6.1-windows-x86_64').with(
command: "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path 'C:/Program Files')).Copyhere(\$sh.namespace((Convert-Path 'C:/Windows/Temp/metricbeat-6.6.1-windows-x86_64.zip')).items(), 16)", # rubocop:disable LineLength
creates: 'C:/Program Files/Metricbeat/metricbeat-6.6.1-windows-x86_64',
)
}
end
it do
is_expected.to contain_file('C:/Program Files').with(ensure: 'directory')
is_expected.to contain_archive('C:/Windows/Temp/metricbeat-6.6.1-windows-x86_64.zip').with(
creates: 'C:/Program Files/Metricbeat/metricbeat-6.6.1-windows-x86_64',
source: 'https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-6.6.1-windows-x86_64.zip',
)
is_expected.to contain_exec('unzip metricbeat-6.6.1-windows-x86_64').with(
command: "\$sh=New-Object -COM Shell.Application;\$sh.namespace((Convert-Path 'C:/Program Files')).Copyhere(\$sh.namespace((Convert-Path 'C:/Windows/Temp/metricbeat-6.6.1-windows-x86_64.zip')).items(), 16)", # rubocop:disable LineLength
creates: 'C:/Program Files/Metricbeat/metricbeat-6.6.1-windows-x86_64',
)
is_expected.to contain_exec('stop service metricbeat-6.6.1-windows-x86_64').with(
creates: 'C:/Program Files/Metricbeat/metricbeat-6.6.1-windows-x86_64',
command: 'Set-Service -Name metricbeat -Status Stopped',
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'metricbeat::params' do
on_supported_os(facterversion: '2.4').each do |os, os_facts|
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# set to strictest setting for testing
# by default Puppet runs at warning level
Puppet.settings[:strict] = :warning
Puppet.settings[:strict_variables] = true
end
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
c.after(:suite) do
Expand Down

0 comments on commit ded9aa2

Please sign in to comment.