diff --git a/data/RedHat-family.yaml b/data/RedHat-family.yaml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/data/RedHat-family.yaml @@ -0,0 +1 @@ + diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 0000000..ae48653 --- /dev/null +++ b/data/common.yaml @@ -0,0 +1,7 @@ +nimsoft::hub_port: 48002 +nimsoft::package_name: 'nimsoft-robot' +nimsoft::package_ensure: 'present' +nimsoft::service_name: 'nimbus' +nimsoft::service_ensure: running +nimsoft::service_enable: true +nimsoft::config_file: '/opt/nms-robot-vars.cfg' diff --git a/hiera.yaml b/hiera.yaml new file mode 100644 index 0000000..c02978c --- /dev/null +++ b/hiera.yaml @@ -0,0 +1,12 @@ +--- +version: 5 +defaults: + datadir: data + data_hash: yaml_data + +hierarchy: + - name: 'Operating System Family' + path: '%{facts.os.family}-family.yaml' + + - name: 'common' + path: 'common.yaml' diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..f000424 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,86 @@ +# Class: nimsoft +# =========================== +# +# Full description of class nimsoft here. +# +# Parameters +# ---------- +# +# Document parameters here. +# +# * `sample parameter` +# Explanation of what this parameter affects and what it defaults to. +# e.g. "Specify one or more upstream ntp servers as an array." +# +# Variables +# ---------- +# +# Here you should define a list of variables that this module would require. +# +# * `sample variable` +# Explanation of how this variable affects the function of this class and if +# it has a default. e.g. "The parameter enc_ntp_servers must be set by the +# External Node Classifier as a comma separated list of hostnames." (Note, +# global variables should be avoided in favor of class parameters as +# of Puppet 2.6.) +# +# Examples +# -------- +# +# @example +# class { 'nimsoft': +# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ], +# } +# +# Authors +# ------- +# +# Author Name +# +# Copyright +# --------- +# +# Copyright 2018 Your name here, unless otherwise noted. +# +class nimsoft ( + String $domain, + String $hub, + Variant $hub_ip, + String $hub_robot_name = undef, + Integer $hub_port, + Stdlib::Absolutepath $config_file, + String $package_name, + String $package_ensure, + String $service_name, + String $service_ensure, + Boolean $service_enable, + Optional[Variant] $robot_ip = undef, +) { + + file{$config_file: + ensure => present, + owner => 'root', + group => 'root', + mode => '0664', + content => template('nimsoft/nms-robot-vars.cfg.erb'), + notify => Exec['RobotConfigurer.sh'], + require => Package[$package_name], + } + + exec{'RobotConfigurer.sh': + path => [ '/bin', '/opt/nimsoft/install', ], + refreshonly => true, + notify => Service[$service_name], + } + + package{$package_name: + ensure => $package_ensure, + } + + service{$service_name: + ensure => $service_ensure, + enable => $service_enable, + require => File[$config_file], + } + +} diff --git a/metadata.json b/metadata.json index e4bc758..800c73b 100644 --- a/metadata.json +++ b/metadata.json @@ -7,7 +7,12 @@ "source": "https://github.com/stschulte/puppet-nimsoft.git", "project_page": "https://github.com/stschulte/puppet-nimsoft", "issues_url": "https://github.com/stschulte/puppet-nimsoft/issues", - "dependencies": [ ], + "dependencies": [ + { + "name": "puppetlabs/stdlib", + "version_requirement": ">= 4.13.1 < 5.0.0" + } + ], "operatingsystem_support": [ { "operatingsystem": "RedHat", diff --git a/templates/nms-robot-vars.cfg.erb b/templates/nms-robot-vars.cfg.erb new file mode 100644 index 0000000..5eabbc9 --- /dev/null +++ b/templates/nms-robot-vars.cfg.erb @@ -0,0 +1,22 @@ +# This file is being maintained by Puppet. +# DO NOT EDIT + +<% if @domain -%> +domain=<%= @domain %> +<% end -%> +<% if @hub -%> +hub=<%= @hub%> +<% end -%> +<% if @hub_ip -%> +hubip=<%= @hub_ip %> +<% end -%> +<% if @robot_ip -%> +robotip=<%= @hubip %> +<% end -%> +<% if @hub_robot_name -%> +hubrobotname=<%= @hub_robot_name %> +<% end -%> +<% if @hub_port -%> +hubport=<%= @hub_port %> +<% end -%> +