Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Make confluence_version a First Class Fact" #94

Merged
merged 1 commit into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "Make confluence_version a First Class Fact"
  • Loading branch information
dhoppe authored Nov 9, 2016
commit 522c42944a6eb1ecc4f1865d06b3424714b2429a
11 changes: 0 additions & 11 deletions lib/facter/confluence_version.rb

This file was deleted.

44 changes: 44 additions & 0 deletions manifests/facts.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# == Class: confluence::facts
#
# Class to add some facts for CONFLUENCE. They have been added as an external fact
# because we do not want to distrubute these facts to all systems.
#
# === Parameters
#
# [*port*]
# port that confluence listens on.
# [*uri*]
# ip that confluence is listening on, defaults to localhost.
#
# === Examples
#
# class { 'confluence::facts': }
#
class confluence::facts(
$ensure = $confluence::facts_ensure
) inherits confluence::params {

if $::puppetversion =~ /Puppet Enterprise/ {
$dir = 'puppetlabs/'
} else {
$dir = ''
}

if ! defined(File["/etc/${dir}facter"]) {
file { "/etc/${dir}facter":
ensure => directory,
}
}
if ! defined(File["/etc/${dir}facter/facts.d"]) {
file { "/etc/${dir}facter/facts.d":
ensure => directory,
}
}

file { "/etc/${dir}facter/facts.d/confluence_facts.sh":
ensure => $ensure,
content => template('confluence/facts.sh.erb'),
mode => '0500',
}

}
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
# puppetlabs-corosync module: 'crm resource stop confluence && sleep 15'
$stop_confluence = 'service confluence stop && sleep 15',

# Enable confluence version fact for running instance
# This required for upgrades
$facts_ensure = 'present',

# Enable SingleSignOn via Crowd

$enable_sso = false,
Expand Down Expand Up @@ -93,6 +97,7 @@
}

anchor { 'confluence::start': } ->
class { '::confluence::facts': } ->
class { '::confluence::install': } ->
class { '::confluence::config': } ~>
class { '::confluence::service': } ->
Expand Down
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$service_file_location = $confluence::params::service_file_location,
$service_file_template = $confluence::params::service_file_template,
$service_lockfile = $confluence::params::service_lockfile,
) inherits confluence::params {
) {

file { $service_file_location:
content => template($service_file_template),
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/confluence_facts_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper.rb'
describe 'confluence' do
describe 'confluence::facts' do
let(:params) do
{ javahome: '/opt/java' }
end
pe_external_fact_file = '/etc/puppetlabs/facter/facts.d/confluence_facts.sh'
external_fact_file = '/etc/facter/facts.d/confluence_facts.sh'

it { is_expected.to contain_file(external_fact_file) }

# Test puppet enterprise shebang generated correctly
context 'with puppet enterprise' do
let(:facts) do
{ puppetversion: '3.4.3 (Puppet Enterprise 3.2.1)' }
end
it do
is_expected.to contain_file(pe_external_fact_file) \
end
end
end
end
26 changes: 0 additions & 26 deletions spec/unit/facter/util/fact_confluence_version_spec.rb

This file was deleted.

18 changes: 18 additions & 0 deletions templates/facts.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
#
# Confluence does not have an API call to get the running version.
#
# This is the best I can come up with right now. It needs to be replaced
# with a better solution.
#
# Facts:
# - confluence_version
#
#VERSION=`ps -ef|grep Dcatalina.home=| egrep -o 'Dcatalina.home=.*([0-9.]{1,}) '|grep -o '......$'|tr -d '[[:space:]]'|grep -Po '(?<=divider-bin-)[^;]+'`
VERSION=`ps -ef|grep Dcatalina.home=| egrep -o 'Dcatalina.home=.*atlassian-confluence-([0-9.]{1,}) '| perl -pe '($_)=/([0-9]+([.][0-9]+)+)/'`
if [ -z "$VERSION" ]
then
echo "confluence_version=unknown";
else
echo "confluence_version=${VERSION}";
fi