Skip to content

Commit

Permalink
remove extra gems
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastien Varrette <[email protected]>
  • Loading branch information
Sebastien Varrette authored and Sebastien Varrette committed May 27, 2017
1 parent 4165ce1 commit 473a68d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
8 changes: 5 additions & 3 deletions lib/puppet/reports/slack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
SLACK_ICON_EMOJI = @config['icon_emoji'] || ''
PUPPETCONSOLE = @config['puppetconsole'] || ''
PUPPETBOARD = @config['puppetboard'] || ''
FOREMAN = @config['foreman'] || ''
# FOREMAN = @config['foreman'] || ''

DISABLED_FILE = "#{@configfile}.disabled"

Expand All @@ -39,8 +39,10 @@ def process
options[:icon_url] = SLACK_ICON_URL unless SLACK_ICON_URL.empty?
options[:icon_emoji] = SLACK_ICON_EMOJI unless SLACK_ICON_EMOJI.empty?
# Prepare the message to display
msg = "Puppet run for `#{self.host}` *#{self.status}* at #{Time.now.asctime} on #{self.configuration_version} in environment _#{self.environment}_." #" Report available "
#Report available <https://#{PUPPETCONSOLE}/#/node_groups/inventory/node/#{self.host}/reports|here>"
report_url = "https://#{PUPPETCONSOLE}/#/node_groups/inventory/node/#{self.host}/reports" unless PUPPETCONSOLE.empty?
report_url = "https://#{PUPPETBOARD}/node/#{self.host}" unless PUPPETBOARD.empty?

msg = "Puppet run for `#{self.host}` *#{self.status}* at #{Time.now.asctime} on #{self.configuration_version} in environment _#{self.environment}_. Report available <#{report_url}|here>."
# TODO: adapt the link
client = SlackNotify::Client.new(options)
client.notify(msg)
Expand Down
19 changes: 8 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- mode: puppet; -*-
# Time-stamp: <Sat 2017-05-27 16:54 svarrette>
# Time-stamp: <Sat 2017-05-27 18:27 svarrette>
# ------------------------------------------------------------------------------
# Class reportslack
#
Expand All @@ -14,8 +14,12 @@
# @param puppetconsole [String]
# @param username [String] Default: 'Puppet'
# Username that this integration will post as.
# @param icon_url [String] Default: wikipedia logo
# @param icon_url [String]
# Icon that is used for messages from this integration.
# @param icon_emoji [String] Default
# EMoji that is used for messages from this integration.
# @param puppetboard [String]
# base hostname of the puppetboard, typically "<fqdn>:<port>"
#
# @author Nicolas Corrarello <[email protected]>,
# Sebastien Varrette aka Falkor <[email protected]>
Expand All @@ -35,7 +39,8 @@
String $puppetconsole = $settings::ca_server,
String $username = $reportslack::params::username,
String $icon_url = $reportslack::params::icon_url,
String $icon_emoji = $reportslack::params::icon_emoji
String $icon_emoji = $reportslack::params::icon_emoji,
String $puppetboard = $reportslack::params::puppetboard
)
inherits reportslack::params
{
Expand All @@ -51,14 +56,6 @@
name => $reportslack::params::gemname,
provider => 'puppetserver_gem'
}
$reportslack::params::extra_gems.each |String $gem| {
if (!defined(Package[$gem])) {
package { $gem:
ensure => 'present',
provider => 'puppetserver_gem'
}
}
}

ini_setting { 'enable_reports':
ensure => present,
Expand Down
16 changes: 7 additions & 9 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- mode: puppet; -*-
# Time-stamp: <Sat 2017-05-27 16:47 svarrette>
# Time-stamp: <Sat 2017-05-27 18:27 svarrette>
# ------------------------------------------------------------------------------
# = Class: reportslack::params
#
Expand Down Expand Up @@ -27,22 +27,20 @@
###########################################

# ensure the presence (or absence) of reportslack
$ensure = 'present'
$channel = '#general'
$username = 'Puppet'
$icon_url = ''
$ensure = 'present'
$channel = '#general'
$username = 'Puppet'
$icon_url = ''
# 'https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png'
$icon_emoji = ''
$icon_emoji = ''
$puppetboard = ''

#### MODULE INTERNAL VARIABLES #########
# (Modify to adapt to unsupported OSes)
#######################################
$gemname = $::operatingsystem ? {
default => 'slack-notify',
}
$extra_gems = $::operatingsystem ? {
default => [ 'yaml' ]
}

$configfile = $::operatingsystem ? {
default => "${settings::confdir}/slack.yaml",
Expand Down
6 changes: 6 additions & 0 deletions templates/slack.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# -*- mode: yaml; -*-
# Slack Notification plugin
---
# Incoming webhook
webhook_url: "<%= @webhook %>"
channel: "<%= @channel %>"
<% unless @puppetconsole.empty? -%>
puppetconsole: "<%= @puppetconsole %>"
<% end -%>
<% unless @puppetboard.empty? -%>
puppetboard: "<%= @puppetboard %>"
<% end -%>
<% unless @username.empty? -%>
username: "<%= @username %>"
<% end -%>
Expand Down

0 comments on commit 473a68d

Please sign in to comment.