5 changes: 2 additions & 3 deletions .fixtures-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ fixtures:
repositories:
apt:
repo: git://github.com/puppetlabs/puppetlabs-apt.git
ref: 6.3.0
stdlib:
repo: git://github.com/puppetlabs/puppetlabs-stdlib.git
ref: 5.1.0
yumrepo_core:
repo: git://github.com/puppetlabs/puppetlabs-yumrepo_core
ref: 1.0.1
puppet_version: ">= 6.0.0"
archive:
repo: git://github.com/voxpupuli/puppet-archive.git
symlinks:
sensu: "#{source_dir}"
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ fixtures:
repo: git://github.com/puppetlabs/puppetlabs-yumrepo_core
ref: 1.0.1
puppet_version: ">= 6.0.0"
archive:
repo: git://github.com/voxpupuli/puppet-archive.git
ref: 'v3.0.0'
symlinks:
sensu: "#{source_dir}"
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--format documentation
22 changes: 9 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ matrix:
env: BEAKER_set="debian-8" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
env: BEAKER_set="ubuntu-1404" BEAKER_PUPPET_COLLECTION=puppet5
bundler_args:
script: bundle exec rake beaker
- rvm: 2.5.3
sudo: required
services: docker
env: BEAKER_set="ubuntu-1404" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker
- rvm: 2.4.4
sudo: required
services: docker
Expand Down Expand Up @@ -149,6 +137,14 @@ matrix:
env: BEAKER_set="amazonlinux-201803" BEAKER_PUPPET_COLLECTION=puppet6
bundler_args:
script: bundle exec rake beaker

allow_failures:
- rvm: 2.4.4
env: PUPPET_GEM_VERSION="~> 5" FIXTURES_YML=".fixtures-latest.yml"
- rvm: 2.5.3
env: PUPPET_GEM_VERSION="~> 6" FIXTURES_YML=".fixtures-latest.yml"
branches:
only:
- master
- /^v\d/
notifications:
email: false
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [v3.3.0](https://github.com/sensu/sensu-puppet/tree/v3.3.0) (2019-05-18)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.2.0...v3.3.0)

**Merged pull requests:**

- \(GH-1111\) Remove Ubuntu 14.04 LTS as it is end of life \(EOL\) [\#1112](https://github.com/sensu/sensu-puppet/pull/1112) ([ghoneycutt](https://github.com/ghoneycutt))
- Fix repo path for EL vagrant [\#1110](https://github.com/sensu/sensu-puppet/pull/1110) ([treydock](https://github.com/treydock))
- Fix cluster tests to work with Sensu Go 5.7 [\#1109](https://github.com/sensu/sensu-puppet/pull/1109) ([treydock](https://github.com/treydock))
- Add Windows support for Sensu Go agent [\#1108](https://github.com/sensu/sensu-puppet/pull/1108) ([treydock](https://github.com/treydock))

## [v3.2.0](https://github.com/sensu/sensu-puppet/tree/v3.2.0) (2019-05-06)
[Full Changelog](https://github.com/sensu/sensu-puppet/compare/v3.1.0...v3.2.0)

Expand Down
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
3. [Usage - Configuration options and additional functionality](#usage)
* [Basic Sensu backend](#basic-sensu-backend)
* [Basic Sensu agent](#basic-sensu-agent)
* [Manage Windows Agent](#manage-windows-agent)
* [Advanced agent](#advanced-agent)
* [Advanced SSL](#advanced-ssl)
* [Enterprise support](#enterprise-support)
Expand Down Expand Up @@ -65,6 +66,8 @@ This module has a soft dependency on the [puppetlabs/apt](https://forge.puppet.c

If using Puppet >= 6.0.0 there is a soft dependency on the [puppetlabs/yumrepo_core](https://forge.puppet.com/puppetlabs/yumrepo_core) module (`>= 1.0.1 < 2.0.0`) for systems using `yum`.

If managing Windows there is a soft dependency on the [puppet/archive](https://forge.puppet.com/puppet/archive) module (`>= 3.0.0 < 4.0.0`).

### Beginning with sensu

This module provides Vagrant definitions that can be used to get started with Sensu.
Expand Down Expand Up @@ -119,6 +122,36 @@ associated to `linux` and `apache-servers` subscriptions.
}
```

### Manage Windows Agent

This module supports Windows Sensu Go agent starting with version 5.7.0.

The Windows package source must be specified as either a URL, a Puppet source or a filesystem path.

Install sensu-go-agent on Windows from URL:

```puppet
class { 'sensu::agent':
package_source => 'https://s3-us-west-2.amazonaws.com/sensu.io/sensu-go/5.7.0/sensu-go-agent_5.7.0.2380_en-US.x64.msi',
}
```

Install sensu-go-agent on Windows from Puppet source:

```puppet
class { 'sensu::agent':
package_source => 'puppet:///modules/profile/sensu/sensu-go-agent.msi',
}
```

If a system already has the necessary MSI present it can be installed without downloading from an URL:

```puppet
class { 'sensu::agent':
package_source => 'C:\Temp\sensu-go-agent.msi',
}
```

### Advanced agent

If you wish to change the `agent` password you must provide the new and old password.
Expand Down Expand Up @@ -514,7 +547,6 @@ Linux.
* EL 7
* Debian 8
* Debian 9
* Ubuntu 14.04 LTS
* Ubuntu 16.04 LTS
* Ubuntu 18.04 LTS
* Amazon 2018.03
Expand Down
28 changes: 28 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ Windows MSI packaging and to avoid surprising upgrades.

Default value: `undef`

##### `package_source`

Data type: `Optional[String[1]]`

Source of package for installing Windows.
Paths with http:// or https:// will be downloaded
Paths with puppet:// or absolute filesystem paths will also be installed.

Default value: `undef`

##### `package_download_path`

Data type: `Optional[Stdlib::Absolutepath]`

Where to download the MSI for Windows. Defaults to `C:\`.
This parameter only used when `package_source` is an URL or when it's a puppet source (`puppet://`).

Default value: `undef`

##### `package_name`

Data type: `String`
Expand Down Expand Up @@ -229,6 +248,15 @@ Sets show_diff parameter for agent.yml configuration file

Default value: `true`

##### `log_file`

Data type: `Optional[Stdlib::Absolutepath]`

Path to agent log file, only for Windows.
Defaults to `C:\ProgramData\sensu\log\sensu-agent.log`

Default value: `undef`

### sensu::backend

Class to manage the Sensu backend.
Expand Down
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ desc 'Generate REFERENCE.md'
task :reference do
sh 'puppet strings generate --format markdown'
end

namespace :acceptance do
desc 'Run acceptance tests against current code for Windows'
RSpec::Core::RakeTask.new(:windows) do |t|
t.pattern = 'spec/acceptance/windows_spec.rb'
end
end
52 changes: 43 additions & 9 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
agent.vm.provision :shell, :inline => "facter --custom-dir=/vagrant/lib/facter sensu_agent"
end

config.vm.define "ubuntu1404-agent", autostart: false do |agent|
agent.vm.box = "ubuntu/trusty64"
agent.vm.hostname = 'ubuntu1404-agent.example.com'
agent.vm.network :private_network, ip: "192.168.52.14"
agent.vm.provision :shell, :path => "tests/provision_basic_debian.sh"
agent.vm.provision :shell, :inline => "puppet apply /vagrant/tests/sensu-agent.pp"
agent.vm.provision :shell, :inline => "facter --custom-dir=/vagrant/lib/facter sensu_agent"
end

config.vm.define "debian9-agent", autostart: false do |agent|
agent.vm.box = "debian/stretch64"
agent.vm.hostname = 'debian9-agent.example.com'
Expand All @@ -135,4 +126,47 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
agent.vm.provision :shell, :inline => "puppet apply /vagrant/tests/sensu-agent.pp"
agent.vm.provision :shell, :inline => "facter --custom-dir=/vagrant/lib/facter sensu_agent"
end

config.vm.define "win2008r2-agent", autostart: false do |agent|
agent.vm.box = "opentable/win-2008r2-standard-amd64-nocm"
agent.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
end
agent.vm.hostname = 'win2008r2-agent'
agent.vm.network :private_network, ip: "192.168.52.25"
agent.vm.network "forwarded_port", host: 3390, guest: 3389, auto_correct: true
agent.vm.provision :shell, :path => "tests/provision_basic_win.ps1"
agent.vm.provision :shell, :inline => '$env:PATH += ";C:\Program Files\Puppet Labs\Puppet\bin" ; iex "puppet apply -v C:/vagrant/tests/sensu-agent.pp"'
agent.vm.provision :shell, :inline => '$env:PATH += ";C:\Program Files\Puppet Labs\Puppet\bin" ; iex "facter --custom-dir=C:\vagrant\lib\facter sensu_agent"'
end

config.vm.define "win2012r2-agent", autostart: false do |agent|
agent.vm.box = "opentable/win-2012r2-standard-amd64-nocm"
agent.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
end
agent.vm.hostname = 'win2012r2-agent'
agent.vm.network :private_network, ip: "192.168.52.24"
agent.vm.network "forwarded_port", host: 3389, guest: 3389, auto_correct: true
agent.vm.provision :shell, :path => "tests/provision_basic_win.ps1"
agent.vm.provision :shell, :inline => 'iex "puppet apply -v C:/vagrant/tests/sensu-agent.pp"'
agent.vm.provision :shell, :inline => 'iex "facter --custom-dir=C:\vagrant\lib\facter sensu_agent"'
end

config.vm.define "win2016-agent", autostart: false do |agent|
agent.vm.box = "mwrock/Windows2016"
agent.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
vb.gui = false
end
agent.vm.hostname = 'win2016-agent'
agent.vm.network :private_network, ip: "192.168.52.26"
agent.vm.network "forwarded_port", host: 3391, guest: 3389, auto_correct: true
agent.vm.provision :shell, :path => "tests/provision_basic_win.ps1"
agent.vm.provision :shell, :inline => 'iex "puppet apply -v C:/vagrant/tests/sensu-agent.pp"'
agent.vm.provision :shell, :inline => 'iex "facter --custom-dir=C:\vagrant\lib\facter sensu_agent"'
end
end
58 changes: 58 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: '{build}-{branch}'
platform:
- x64
build: off
max_jobs: 2
branches:
only:
- master
- /^v\d/
cache:
- C:\downloads
- C:\vendor\bundle
init:
- ps: $env:GEM_SOURCE = "http://rubygems.org"
install:
- set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
- ps: |
if (!(Test-Path C:\downloads)) { mkdir C:\downloads | Out-Null }
$log = "C:/puppet-agent.log"
$agent_url = "https://downloads.puppetlabs.com/windows/${ENV:PUPPET_REPO}/puppet-agent-x64-latest.msi"
Write-Output "Installing Puppet from $agent_url"
Write-Output "Log will be written to $log"
if ( Test-Path $log ) { Remove-Item $log }
cd C:\downloads
if (!(Test-Path "puppet-agent-x64-latest.msi")) { Start-FileDownload $agent_url }
Start-Process msiexec.exe -Wait -NoNewWindow -ArgumentList @("/i", "C:\downloads\puppet-agent-x64-latest.msi", "/qn", "/l*", "$log")
cd $ENV:APPVEYOR_BUILD_FOLDER
- ps: Copy-Item -Path $ENV:APPVEYOR_BUILD_FOLDER -Destination C:/ProgramData/PuppetLabs/code/environments/production/modules/sensu -Recurse
- ps: Copy-Item -Path "${ENV:APPVEYOR_BUILD_FOLDER}/tests/ssl" -Destination C:/ProgramData/PuppetLabs/puppet/etc/ssl -Recurse
- ps: Copy-Item -Path "${ENV:APPVEYOR_BUILD_FOLDER}/lib/facter" -Destination C:/ProgramData/PuppetLabs/puppet/cache/lib/facter -Recurse
- set PATH=C:\Program Files\Puppet Labs\Puppet\bin;%PATH%
- puppet --version
- puppet module install puppetlabs-stdlib
- puppet module install puppet-archive
- puppet config set --section main certname sensu_agent
- facter -p --debug
- ruby -v
- gem update --system 2.7.9
- gem -v
- bundle -v
- bundle install --jobs 4 --retry 2 --path C:\vendor\bundle
test_script:
- bundle exec rake acceptance:windows
image:
# Windows 2012 R2
- Visual Studio 2015
# Windows 2016
- Visual Studio 2017
environment:
matrix:
- PUPPET_GEM_VERSION: '~>5.x'
PUPPET_REPO: puppet5
RUBY_VERSION: 24-x64
- PUPPET_GEM_VERSION: '~>6.x'
PUPPET_REPO: puppet6
RUBY_VERSION: 25-x64
matrix:
fast_finish: false
8 changes: 7 additions & 1 deletion data/os/windows.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
sensu::etc_dir: 'C:/opt/sensu'
sensu::manage_repo: false
sensu::etc_dir: 'C:\ProgramData\Sensu\config'
sensu::ssl_dir: 'C:\ProgramData\Sensu\config\ssl'
sensu::agent::package_name: 'Sensu Agent'
sensu::agent::package_download_path: 'C:\'
sensu::agent::log_file: 'C:\ProgramData\sensu\log\sensu-agent.log'
sensu::agent::service_name: SensuAgent
13 changes: 11 additions & 2 deletions lib/facter/sensu_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@

module SensuFacts
def self.which(cmd)
path = Facter::Core::Execution.which(cmd)
path = nil
if File.exists?("C:\\Program Files\\sensu\\sensu-agent\\bin\\#{cmd}.exe")
path = "C:\\Program Files\\sensu\\sensu-agent\\bin\\#{cmd}.exe"
else
path = Facter::Core::Execution.which(cmd)
end
path
end

def self.get_version_info(cmd)
path = self.which(cmd)
return nil unless path
output = Facter::Core::Execution.exec("#{path} version 2>&1")
if Facter.value(:kernel) == 'windows'
output = Facter::Core::Execution.exec("\"#{path}\" version")
else
output = Facter::Core::Execution.exec("#{path} version 2>&1")
end
version = nil
if output =~ /^#{cmd} version ([^,]+)/
version = $1.split('#')[0]
Expand Down
Loading