Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add loggly::uninstall define, fix syslog-ng include, fix and add beak… #20

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

add loggly::uninstall define, fix syslog-ng include, fix and add beak…

…er acceptance tests
  • Loading branch information
drewrothstein committed Aug 13, 2016
commit 3c6e7b1a84f1f9d57aea7f1d3cd55bfd110a6943
@@ -2,6 +2,6 @@ fixtures:
forge_modules:
stdlib:
repo: 'puppetlabs/stdlib'
ref: '4.5.1'
ref: '4.12.0'
symlinks:
loggly: "#{source_dir}"
@@ -5,3 +5,4 @@ spec/fixtures
.vagrant
.bundle
vendor
.DS_Store
@@ -9,3 +9,4 @@ Ryan Coleman
jasons-loggly
maxgutman
psquickitjayant
drewrothstein
@@ -354,7 +354,7 @@ DEPENDENCIES
beaker-rspec
guard-rake
metadata-json-lint
puppet (~> 3.7.0)
puppet (~> 3.7.5)
puppet-blacksmith
puppetlabs_spec_helper
rake
@@ -364,3 +364,6 @@ DEPENDENCIES
travis
travis-lint
vagrant-wrapper

BUNDLED WITH
1.12.5
@@ -72,10 +72,12 @@
# include a configuration snippet directory, so we ensure it is
# present
file_line { 'snippet_dir':
ensure => present,
path => '/etc/syslog-ng/syslog-ng.conf',
line => '@include "/etc/syslog-ng/conf.d/"',
before => File['/etc/syslog-ng/conf.d/22-loggly.conf'],
ensure => present,
path => '/etc/syslog-ng/syslog-ng.conf',
line => '@include "/etc/syslog-ng/conf.d/"',
replace => false,
match => '^@include "/etc/syslog-ng/conf.d.*$',
before => File['/etc/syslog-ng/conf.d/22-loggly.conf'],
}

# Packages available from the EPEL repo for syslog-ng on
@@ -0,0 +1,84 @@
# == Define: loggly::uninstall
#
# Removes loggly in its entirety.
# If any custom logs were specified, they must be specified here for removal.
#
# === Parameters
#
# [*logname*]
# The label of the log file to remove configuration from if it was previously specified.
#
# [*filepath*]
# The fully qualified path to the file to remove configuration from.
#
# === Variables
#
# [*_t*]
# An internal temp variable used for string parsing.
#
# [*_logname*]
# An internal temp variable used for string parsing.
#
# === Examples
#
# loggly::uninstall { 'remove': }
#
# loggly::uninstall { '/phil/collins': }
#
# loggly::uninstall { '/phil/collins':
# logname => 'in_the_air_tonight',
# }
#
# === Authors
#
# Drew Rothstein <drew@drewrothstein.com>
#
define loggly::uninstall (
$logname = undef,
$filepath = $title,
) {
include loggly::params

file { $::loggly::params::base_dir:
ensure => absent,
recurse => true,
purge => true,
force => true,
}

file { '/etc/rsyslog.d/22-loggly.conf':
ensure => absent,
notify => Exec['restart_rsyslogd'],
}

file { '/etc/syslog-ng/conf.d/22-loggly.conf':
ensure => absent,
notify => Exec['restart_syslog_ng'],
}

if is_absolute_path($filepath) {
$_t = split($filepath, '/')
$_logname = pick($logname, $_t[-1])

validate_string($_logname)

file { "/etc/rsyslog.d/${_logname}.conf":
ensure => absent,
notify => Exec['restart_rsyslogd'],
}
}

exec { 'restart_rsyslogd':
command => 'service rsyslog restart',
path => [ '/usr/sbin', '/sbin', '/usr/bin/', '/bin', ],
refreshonly => true,
}

exec { 'restart_syslog_ng':
command => 'service syslog-ng restart',
path => [ '/usr/sbin', '/sbin', '/usr/bin/', '/bin', ],
refreshonly => true,
}
}

# vim: syntax=puppet ft=puppet ts=2 sw=2 nowrap et
@@ -11,7 +11,7 @@
"dependencies": [
{
"name": "puppetlabs-stdlib",
"version_requirement": ">= 4.2.0 < 5.0.0"
"version_requirement": ">= 4.12.0 < 5.0.0"
}
],
"requirements": [
@@ -1,26 +1,37 @@
require 'spec_helper_acceptance'

describe 'loggly class' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'loggly':
base_dir => '/usr/local/loggly',
enable_tls => true,
}
EOS

context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'loggly': }
EOS
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file('/usr/local/loggly') do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
end

describe package('loggly') do
it { is_expected.to be_installed }
end
describe file('/usr/local/loggly/certs') do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
end

describe service('loggly') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
describe file('/usr/local/loggly/certs/loggly_full.crt') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
it { should contain 'BEGIN CERTIFICATE' }
it { should contain 'END CERTIFICATE' }
end
end
@@ -6,6 +6,7 @@ HOSTS:
box : centos-64-x64-vbox4210-nocm
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
hypervisor : vagrant

CONFIG:
log_level: verbose
type: foss
@@ -6,6 +6,7 @@ HOSTS:
box: puppetlabs/centos-6.6-64-nocm
box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.6-64-nocm
hypervisor: vagrant

CONFIG:
log_level: verbose
type: foss
@@ -3,8 +3,8 @@ HOSTS:
roles:
- master
platform: el-7-x86_64
box: chef/centos-7.0
box_url: https://vagrantcloud.com/chef/boxes/centos-7.0
box: centos/7
box_url: https://atlas.hashicorp.com/centos/boxes/7
hypervisor: vagrant

CONFIG:
@@ -0,0 +1,12 @@
HOSTS:
debian-711-x64:
roles:
- master
platform: debian-7-amd64
box: debian/wheezy64
box_url: https://atlas.hashicorp.com/debian/boxes/wheezy64
hypervisor: vagrant

CONFIG:
log_level: verbose
type: foss

This file was deleted.

@@ -0,0 +1,34 @@
require 'spec_helper_acceptance'

describe 'rsyslog class' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'loggly::rsyslog':
customer_token => '00000000-0000-0000-0000-000000000000',
cert_path => '/usr/local/loggly/certs',
enable_tls => true,
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe package('rsyslog-gnutls') do
it { is_expected.to be_installed }
end

describe service('rsyslog') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe file('/etc/rsyslog.d/22-loggly.conf') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
it { should contain 'LogglyFormat' }
end
end
@@ -0,0 +1,58 @@
require 'spec_helper_acceptance'

describe 'syslog_ng class' do
# Using puppet_apply as a helper
# Install syslog-ng as this module assumes it is installed outside of it
it 'should work idempotently with no errors' do
case fact('operatingsystem')
when 'CentOS'
pp = <<-EOS
package { 'epel-release':
ensure => 'installed',
}
package { 'syslog-ng':
ensure => 'installed',
require => Package['epel-release'],
}
class { 'loggly::syslog_ng':
customer_token => '00000000-0000-0000-0000-000000000000',
cert_path => '/usr/local/loggly/certs',
enable_tls => true,
}
EOS
else
pp = <<-EOS
package { 'syslog-ng':
ensure => 'installed',
}
class { 'loggly::syslog_ng':
customer_token => '00000000-0000-0000-0000-000000000000',
cert_path => '/usr/local/loggly/certs',
enable_tls => true,
}
EOS
end
# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe package('syslog-ng') do
it { is_expected.to be_installed }
end

describe service('syslog-ng') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe file('/etc/syslog-ng/conf.d/22-loggly.conf') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
it { should contain 'LogglyFormat' }
end
end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.