diff --git a/README.md b/README.md index c3d19a9..92812bf 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ - [Additional UI users](#additional-ui-users) - [Adding contacts](#adding-contacts) - [Adding contact groups](#adding-contact-groups) + - [Adding host groups](#adding-host-groups) - [Repo Documentation](#repo-documentation) - [Dependencies](#dependencies) - [Deployment](#deployment) @@ -98,6 +99,19 @@ In order to add contact groups for the notifications, address the define `confdr } ``` +### Adding host groups + +In order to add host groups, address the define `confdroid_nagios::nagios::objects::add_hostgroups` in your config repo, site.pp etc. like this: + +```puppet + confdroid_nagios::nagios::objects::add_hostgroups { 'example_hostgroup': + ng_hostgroup_name => 'example_hostgroup', + ng_hostgroup_alias => 'Example Hostgroup', + } +``` + +Hosts will be populated through the target.pp dynamically. + ## Repo Documentation See the full Puppet documentation including parameters in `docs/index.html` @@ -127,7 +141,7 @@ node 'example.example.net' { In order to apply parameters through Foreman, **__confdroid_nagios::params__*- must be added to the host or host group in question. -See [more details about class deployment on Confdroid.com](https://confdroid.com/2017/05/deploying-our-puppet-modules/). +See [more details about class deployment on confdroid.com](https://confdroid.com/2017/05/deploying-our-puppet-modules/). ## PuppetDB @@ -158,5 +172,5 @@ All files and directories are configured with correct selinux context. If selinu ## Disclaimer -ConfDroid as entity is entirely independent from Puppet. We provide custom configuration modules, written for specific purposes and specific environments. +confdroid as entity is entirely independent from Puppet. We provide custom configuration modules, written for specific purposes and specific environments. The modules are tested and supported only as documented, and require testing in designated environments (i.e. lab or development environments) for parameter tuning etc. before deploying into production environments. diff --git a/manifests/nagios/config.pp b/manifests/nagios/config.pp index d8df6e6..a39f034 100644 --- a/manifests/nagios/config.pp +++ b/manifests/nagios/config.pp @@ -11,8 +11,7 @@ class confdroid_nagios::nagios::config ( #require confdroid_nagios::nagios::objects::template_rules require confdroid_nagios::nagios::objects::add_contact_rules require confdroid_nagios::nagios::objects::add_contactgroups_rules - #require confdroid_nagios::nagios::objects::hostgroups - #require confdroid_nagios::nagios::objects::add_hostgroup_rules + require confdroid_nagios::nagios::objects::add_hostgroup_rules #require confdroid_nagios::nagios::objects::servicegroups #require confdroid_nagios::nagios::objects::add_servicegroup_rules #require confdroid_nagios::nagios::objects::timeperiods diff --git a/manifests/nagios/objects/add_hostgroup_rules.pp b/manifests/nagios/objects/add_hostgroup_rules.pp new file mode 100644 index 0000000..4494ee2 --- /dev/null +++ b/manifests/nagios/objects/add_hostgroup_rules.pp @@ -0,0 +1,39 @@ +## confdroid_nagios::nagios::objects::add_hostgroup_rules.pp +# Module name: confdroid_nagios +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary Class manages /etc/nagios_conf.d/nagios_hostgroups_add.cfg and +# additional hostgroups through external Puppet rules via define. +# @example +# confdroid_nagios::nagios::objects::add_hostgroups { 'example_hostgroup': +# ng_hostgroup_name => 'example_hostgroup', +# ng_hostgroup_alias => 'Example Hostgroup', +# } +################################################################################ +class confdroid_nagios::nagios::objects::add_hostgroup_rules ( + +) inherits confdroid_nagios::params { + if $ng_nagios_server == $fqdn { + # manage /etc/nagios_conf.d/nagios_hostgroups_add.cfg + + concat { $ng_tgt_hostgroup_add: + ensure => present, + path => $ng_tgt_hostgroup_add, + owner => 'nagios', + group => 'nagios', + mode => '0640', + selrange => s0, + selrole => object_r, + seltype => nagios_etc_t, + seluser => system_u, + notify => Service[ng_nagios_service], + } + + # manage file header + + concat::fragment { 'hostgroups_header': + target => $ng_tgt_hostgroup_add, + content => template($ng_tgt_hostgrp_head_erb), + order => '000', + } + } +} diff --git a/manifests/nagios/objects/add_hostgroups.pp b/manifests/nagios/objects/add_hostgroups.pp new file mode 100644 index 0000000..d1560e0 --- /dev/null +++ b/manifests/nagios/objects/add_hostgroups.pp @@ -0,0 +1,32 @@ +## confdroid_nagios::nagios::objects::add_hostgroups.pp +# Module name: confdroid_nagios +# Author: 12ww1160 (12ww1160@confdroid.com) +# @summary define populates /etc/nagios/conf.d/nagios_hostgroups_add through +# external Puppet rules. +# @example +# confdroid_nagios::nagios::objects::add_hostgroups { 'example_hostgroup': +# ng_hostgroup_name => 'example_hostgroup', +# ng_hostgroup_alias => 'Example Hostgroup', +# } +# @param [string] ng_hostgroup_name Specify the hostgroup short name. +# @param [string] ng_hostgroup_alias Specify the hostgroup alias (long name). +# @param [string] ng_hostgroup_register Whether to register the hostgroup. +############################################################################### +define confdroid_nagios::nagios::objects::add_hostgroups ( + + Optional[String] $ng_hostgroup_name = undef, + Optional[String] $ng_hostgroup_alias = undef, + String $ng_hostgroup_register = '1', + +) { + $ng_nagios_server = $confdroid_nagios::params::ng_nagios_server + $ng_tgt_hostgroup_add = $confdroid_nagios::params::ng_tgt_hostgroup_add + $ng_tgt_hostgrp_rule_erb = $confdroid_nagios::params::ng_tgt_hostgrp_rule_erb + + if $ng_nagios_server == $fqdn { + concat::fragment { $name: + target => $ng_tgt_hostgroup_add, + content => template($ng_tgt_hostgrp_rule_erb), + } + } +} diff --git a/manifests/nagios/resources/resource_df.pp b/manifests/nagios/resources/resource_df.pp index 346e5ce..3de1356 100644 --- a/manifests/nagios/resources/resource_df.pp +++ b/manifests/nagios/resources/resource_df.pp @@ -1,6 +1,6 @@ ## confdroid_nagios::nagios::resources::resource_df.pp # Module name: confdroid_nagios -# Author: 12ww1160 (12ww1160@ConfDroid.com) +# Author: 12ww1160 (12ww1160@confdroid.com) # @summary define manages the resources in/etc/nagios/private/resources.cfg # @param [String] ng_user_arg_name the name of user argument i.e. $user1$ # @param [String] ng_user_arg_value the value of t user argument i.e. $user1$ @@ -9,9 +9,9 @@ ############################################################################# define confdroid_nagios::nagios::resources::resource_df ( - Optional[String] $ng_user_arg_name = undef, - Optional[String] $ng_user_arg_value = undef, - Optional[String] $ng_user_arg_comment = undef, + Optional[String] 'nagios'_arg_name = undef, + Optional[String] 'nagios'_arg_value = undef, + Optional[String] 'nagios'_arg_comment = undef, String $ng_resource_rule_erb = 'confdroid_nagios/nagios/resource_cfg_rule.erb', ) { diff --git a/manifests/params.pp b/manifests/params.pp index a0ad36f..c870aad 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -108,9 +108,9 @@ class confdroid_nagios::params ( String $ng_swap_crit = '10', String $ng_swap_ensure = 'present', # users - String $ng_users_warn = '20', - String $ng_users_crit = '50', - String $ng_users_ensure = 'present', + String 'nagios's_warn = '20', + String 'nagios's_crit = '50', + String 'nagios's_ensure = 'present', #total procs String $ng_procs_tot_warn = '330', String $ng_procs_tot_crit = '400', diff --git a/templates/nagios/nagios_cfg.erb b/templates/nagios/nagios_cfg.erb index 9bf8315..84546fc 100644 --- a/templates/nagios/nagios_cfg.erb +++ b/templates/nagios/nagios_cfg.erb @@ -15,7 +15,6 @@ log_file=<%= @ng_log_file %> # or at nagios.org cfg_file=/etc/nagios/objects/commands.cfg -cfg_file=/etc/nagios/objects/contacts.cfg cfg_file=/etc/nagios/objects/timeperiods.cfg cfg_file=/etc/nagios/objects/templates.cfg