Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.

Commit

Permalink
Add support for splay, modulepath and symlinks
Browse files Browse the repository at this point in the history
* Add support for adding splay to agent configuration
* Add support for removing modulepath form agent configuration
* Add support for not adding symlinks in /usr/bin
* Add fixtures.yml so tests can work
* Switch from simple string equality to versioncmp for upgrades
  • Loading branch information
Alexander J. Maidak committed Oct 16, 2015
1 parent 9e71286 commit 5994621
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 29 deletions.
7 changes: 7 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fixtures:
repositories:
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
wget: https://github.com/maestrodev/puppet-wget
inifile: https://github.com/puppetlabs/puppetlabs-inifile
symlinks:
puppet_ent_agent: "#{source_dir}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.bundle
51 changes: 51 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.8)
diff-lcs (1.2.5)
facter (2.4.4)
CFPropertyList (~> 2.2.6)
hiera (3.0.1)
json_pure
json_pure (1.8.2)
metaclass (0.0.4)
mocha (1.1.0)
metaclass (~> 0.0.1)
puppet (4.2.2)
facter (> 2.0, < 4)
hiera (>= 2.0, < 4)
json_pure
puppet-lint (1.1.0)
puppet-syntax (2.0.0)
rake
puppetlabs_spec_helper (0.10.3)
mocha
puppet-lint
puppet-syntax
rake
rspec-puppet
rake (10.4.2)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-puppet (2.2.0)
rspec
rspec-support (3.3.0)

PLATFORMS
ruby

DEPENDENCIES
facter (>= 1.7.0)
puppet (>= 3.3)
puppet-lint (>= 0.3.2)
puppetlabs_spec_helper (>= 0.1.0)
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@ If the pe_repo package repository of the specified version is not present on the

Hostname of a PE master with the required pe_repo classes properly applied to it. Defaults to the PE master that compiled the agent's catalog.

####`agent_server` & `agent_caserver` & `agent_fileserver` & `agent_environment`
####`agent_server` & `agent_caserver` & `agent_fileserver` & `agent_environment` & `agent_splay`

Sets the server, ca_server, archive_file_server and environment settings in the agent's puppet.conf file.

The server settings default to undef and do not manage the settings unless overridden in node classification. *agent_environment* defaults to 'production'.

####`agent_remove_modulepath`

If set to true the module will ensure the depracated modulepath setting is removed from puppet.conf default is false

####`manage_symlinks`

If set to true the module will create symlinks to hiera, puppet, facter, etc in /usr/bin default is true

####`staging_dir`

The directory that will be used on non-Windows hosts to temporarily hold the PE Agent installation script. This defaults to '/tmp/puppet_ent_agent'.
Expand Down
41 changes: 34 additions & 7 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# manages puppet.conf
class puppet_ent_agent::config {
$config = $::puppet_ent_agent::config
$agent_server = $::puppet_ent_agent::agent_server
$agent_caserver = $::puppet_ent_agent::agent_caserver
$agent_environment = $::puppet_ent_agent::agent_environment
$agent_fileserver = $::puppet_ent_agent::agent_fileserver
$config = $::puppet_ent_agent::config
$agent_server = $::puppet_ent_agent::agent_server
$agent_caserver = $::puppet_ent_agent::agent_caserver
$agent_environment = $::puppet_ent_agent::agent_environment
$agent_fileserver = $::puppet_ent_agent::agent_fileserver
$agent_splay = $::puppet_ent_agent::agent_splay
$agent_remove_modulepath = $::puppet_ent_agent::agent_remove_modulepath
$manage_symlinks = $::puppet_ent_agnet::manage_symlinks

Ini_setting {
ensure => present,
Expand All @@ -16,7 +19,9 @@

case $::osfamily {
'AIX': {
include ::puppet_ent_agent::config::symlinks
if($manage_symlinks) {
include ::puppet_ent_agent::config::symlinks
}

file { $config:
ensure => file,
Expand All @@ -31,7 +36,9 @@
}
}
default: {
include ::puppet_ent_agent::config::symlinks
if($manage_symlinks) {
include ::puppet_ent_agent::config::symlinks
}

file { $config:
ensure => file,
Expand Down Expand Up @@ -70,4 +77,24 @@
value => $agent_environment,
}
}

if $agent_splay {
ini_setting { 'agent_splay':
setting => 'splay',
value => $agent_splay,
}
}
else {
ini_setting { 'agent_splay':
ensure => absent,
setting => 'splay'
}
}

if $agent_remove_modulepath {
ini_setting { 'agent_modulepath':
ensure => absent,
setting => 'modulepath',
}
}
}
26 changes: 16 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@
# Sample Usage:
#
class puppet_ent_agent (
$config = $puppet_ent_agent::params::config,
$ensure = $puppet_ent_agent::params::ensure,
$master = $puppet_ent_agent::params::master,
$agent_server = $puppet_ent_agent::params::agent_server,
$agent_caserver = $puppet_ent_agent::params::agent_caserver,
$agent_fileserver = $puppet_ent_agent::params::agent_fileserver,
$agent_environment = $puppet_ent_agent::params::agent_environment,
$staging_dir = $puppet_ent_agent::params::staging_dir,
$windows_source = $puppet_ent_agent::params::windows_source,
$windows_task_min = $puppet_ent_agent::params::windows_task_min,
$config = $puppet_ent_agent::params::config,
$ensure = $puppet_ent_agent::params::ensure,
$master = $puppet_ent_agent::params::master,
$agent_server = $puppet_ent_agent::params::agent_server,
$agent_caserver = $puppet_ent_agent::params::agent_caserver,
$agent_fileserver = $puppet_ent_agent::params::agent_fileserver,
$agent_environment = $puppet_ent_agent::params::agent_environment,
$agent_splay = $puppet_ent_agent::params::agent_splay,
$agent_remove_modulepath = $puppet_ent_agent::params::agent_remove_modulepath,
$staging_dir = $puppet_ent_agent::params::staging_dir,
$manage_symlinks = $puppet_ent_agent::params::manage_symlinks,
$windows_source = $puppet_ent_agent::params::windows_source,
$windows_task_min = $puppet_ent_agent::params::windows_task_min,
) inherits puppet_ent_agent::params {

validate_absolute_path($config)
Expand All @@ -33,8 +36,11 @@
validate_string($agent_caserver)
validate_string($agent_fileserver)
validate_string($agent_environment)
validate_string($agent_splay)
validate_string($staging_dir)
validate_string($windows_source)
validate_bool($agent_remove_modulepath)
validate_bool($manage_symlinks)
validate_integer($windows_task_min)

class { '::puppet_ent_agent::install': } ->
Expand Down
2 changes: 1 addition & 1 deletion manifests/install/nix.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
default: { $group = 'root' }
}

if $::pe_version != $version {
if (versioncmp($version,$::pe_version) > 0) {

file { $staging_dir:
ensure => directory,
Expand Down
24 changes: 15 additions & 9 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# - $agent_caserver: PE certificate authority (CA) server
# - $agent_fileserver: PE filebucket server
# - $agent_environment: desired default environment
# - $agent_splay: enable splay on the agent
# - $agent_remove_modulepath: remove the deprecated modulepath setting from puppet.conf
# - $manage_symlinks: create symlinks in /usr/bin
# - $staging_dir: temp directory to use on non-Windows servers
# - $windows_source: UNC path to file share hosting Windows PE MSI installers
# _ $windows_task_min: (int) will schedule a task to run upgrade in x mins
Expand All @@ -35,13 +38,16 @@
else {
$config = '/etc/puppetlabs/puppet/puppet.conf'
}
$ensure = 'latest'
$master = $::settings::server
$agent_server = undef
$agent_caserver = undef
$agent_fileserver = undef
$agent_environment = 'production'
$staging_dir = '/tmp/puppet_ent_agent'
$windows_source = undef
$windows_task_min = '10' # run a scheduled task to upgrade PE agent in x mins
$ensure = 'latest'
$master = $::settings::server
$agent_server = undef
$agent_caserver = undef
$agent_fileserver = undef
$agent_environment = 'production'
$agent_splay = undef
$agent_remove_modulepath = false
$staging_dir = '/tmp/puppet_ent_agent'
$windows_source = undef
$windows_task_min = '10' # run a scheduled task to upgrade PE agent in x mins
$manage_symlinks = true
}
1 change: 0 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'spec_helper'
describe 'puppet_ent_agent' do

context 'with defaults for all parameters' do
it { should contain_class('puppet_ent_agent') }
end
Expand Down

0 comments on commit 5994621

Please sign in to comment.