diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..9d6802a --- /dev/null +++ b/.fixtures.yml @@ -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}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..677c465 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.bundle diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e6f1985 --- /dev/null +++ b/Gemfile.lock @@ -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) diff --git a/README.md b/README.md index a585041..c994d84 100644 --- a/README.md +++ b/README.md @@ -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'. diff --git a/manifests/config.pp b/manifests/config.pp index f4efed6..4b75f05 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -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, @@ -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, @@ -31,7 +36,9 @@ } } default: { - include ::puppet_ent_agent::config::symlinks + if($manage_symlinks) { + include ::puppet_ent_agent::config::symlinks + } file { $config: ensure => file, @@ -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', + } + } } diff --git a/manifests/init.pp b/manifests/init.pp index d02e4c4..a32638a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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) @@ -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': } -> diff --git a/manifests/install/nix.pp b/manifests/install/nix.pp index f88165d..33264b7 100644 --- a/manifests/install/nix.pp +++ b/manifests/install/nix.pp @@ -11,7 +11,7 @@ default: { $group = 'root' } } - if $::pe_version != $version { + if (versioncmp($version,$::pe_version) > 0) { file { $staging_dir: ensure => directory, diff --git a/manifests/params.pp b/manifests/params.pp index bd71852..535358a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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 @@ -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 } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 8f4ee18..c6ed022 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -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