commit 6bc7b1ede693cebd8d86ed2ec15164ce315ac7bd Author: Tom De Vylder Date: Fri Feb 20 10:40:45 2015 +0100 Initial commit diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..83e7679 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,8 @@ +fixtures: + repositories: + stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' + vcsrepo: 'git://github.com/puppetlabs/puppetlabs-vcsrepo.git' + + symlinks: + icingaweb2: "#{source_dir}" + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5f38d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +.bundle +Gemfile.lock +pkg +spec/fixtures +vendor diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..b0d12b7 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1 @@ +--no-80chars-check diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..10c70f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +language: ruby + +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 + - 2.1.3 + +matrix: + allow_failures: + - rvm: 1.8.7 + - rvm: 2.0.0 + env: PUPPET_VERSION="2.7" + - rvm: 2.1.3 + env: PUPPET_VERSION="2.7" + +before_install: + - 'gem install bundler' + +script: + - bundle install + - bundle update + - bundle exec rake + +env: + - PUPPET_VERSION="2.7" + - PUPPET_VERSION="3.0" + - PUPPET_VERSION="3.1" + - PUPPET_VERSION="3.2" + - PUPPET_VERSION="3.3" + - PUPPET_VERSION="3.4" + - PUPPET_VERSION="3.5" + - PUPPET_VERSION="3.6" + - PUPPET_VERSION="3.7" + +branches: + only: + - master + - develop + diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..fc602f9 --- /dev/null +++ b/Gemfile @@ -0,0 +1,21 @@ +source 'https://rubygems.org' + +puppetversion = ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : ['>= 3.7.4'] +gem 'puppet', puppetversion + +if puppetversion =~ /^3/ + ## rspec-hiera-puppet is puppet 3 only + gem 'rspec-hiera-puppet', '>=1.0.0' +end + +facterversion = ENV.key?('FACTER_VERSION') ? "~> #{ENV['FACTER_VERSION']}" : ['>= 2.4.1'] + +gem 'facter', facterversion + +gem 'rake' +gem 'rspec' +gem 'puppet-lint', '>=1.1.0' +gem 'rspec-puppet', :git => 'https://github.com/rodjek/rspec-puppet.git' +gem 'puppetlabs_spec_helper', '>=0.8.2' +gem 'puppet-syntax' + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b58f924 --- /dev/null +++ b/LICENSE @@ -0,0 +1,14 @@ + Copyright (C) 2012 Tom De Vylder + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..83ab9f7 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Puppet icingaweb2 + +## Requirements + +* [stdlib](https://github.com/puppetlabs/puppetlabs-stdlib) +* [vcsrepo](https://github.com/puppetlabs/puppet-vcsrepo) + +Debian and derivatives only: + +* Puppetlabs [apt module](https://github.com/puppetlabs/puppetlabs-apt) or +* Camptocamp [apt module](https://github.com/camptocamp/puppet-apt) + +## Example usage + +### Install IcingaWeb2 + + node /box/ { + include icingaweb2 + } + +### Install method: packages + + node /box/ { + class { 'icingaweb2': + install_method => 'package', + } + } + +### Install method: Git + + node /box/ { + class { 'icingaweb2': + install_method => 'git', + } + } + +### Manage repository + + node /box/ { + class { 'icingaweb2': + manage_repo => true, + } + } + +## Contributing + +* Fork it +* Create a feature branch (`git checkout -b my-new-feature`) +* Run rspec tests (`bundle exec rake spec`) +* Commit your changes (`git commit -am 'Added some feature'`) +* Push to the branch (`git push origin my-new-feature`) +* Create new Pull Request diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..53cf884 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,40 @@ +# == Class icingaweb2::config +# +class icingaweb2::config { + File { + require => Class['::icingaweb2::install'], + owner => $::icingaweb2::config_user, + group => $::icingaweb2::config_group, + mode => $::icingaweb2::config_file_mode, + } + + file { + $::icingaweb2::config_dir: + ensure => directory, + mode => $::icingaweb2::config_dir_mode, + recurse => $::icingaweb2::config_dir_recurse; + + "${::icingaweb2::config_dir}/enabledModules": + ensure => directory; + + "${::icingaweb2::config_dir}/modules": + ensure => directory; + + "${::icingaweb2::config_dir}/authentication.ini": + ensure => present, + content => template('icingaweb2/authentication.ini.erb'); + + "${::icingaweb2::config_dir}/config.ini": + ensure => present, + content => template('icingaweb2/config.ini.erb'); + + "${::icingaweb2::config_dir}/resources.ini": + ensure => present, + content => template('icingaweb2/resources.ini.erb'); + + "${::icingaweb2::config_dir}/roles.ini": + ensure => present, + content => template('icingaweb2/roles.ini.erb'); + } +} + diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..97e8305 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,108 @@ +# == Class icingaweb2 +# +# $config_dir:: Location of the main configuration directory. +# Default: operating system specific. +# +# $config_dir_mode:: Posix file mode for configuration directories. +# Default: 0755. +# +# $config_dir_recurse:: Apply the same posix permissions as $config_dir to any +# directory contained in $config_dir. +# Default: false. +# +# $config_file_mode:: Posix file mode for configuration files. +# Default: 0644. +# +# $config_group:: Posix group for configuration files. +# Default: operating system specific. +# +# $config_user:: Posix user for configuration files. +# Default: operating system specific. +# +# $manage_repo:: Add a custom package repository. +# Default: false. +# +# $pkg_deps:: Any dependencies that need to be resolved before +# installing the main package. +# Default: operating system specific. +# +# $pkg_ensure:: Ensure state for packages. +# Default: present. +# +# $pkg_list:: An array containing the main package and possibly +# a number of dependencies. +# Default: operating system specific. +# +# $web_root:: pending +# Default: operating system specific. +# +class icingaweb2 ( + $config_dir = $::icingaweb2::params::config_dir, + $config_dir_mode = $::icingaweb2::params::config_dir_mode, + $config_dir_recurse = $::icingaweb2::params::config_dir_recurse, + $config_file_mode = $::icingaweb2::params::config_file_mode, + $config_group = $::icingaweb2::params::config_group, + $config_user = $::icingaweb2::params::config_user, + $git_repo = $::icingaweb2::params::git_repo, + $git_revision = $::icingaweb2::params::git_revision, + $ido_db = $::icingaweb2::params::ido_db, + $ido_db_host = $::icingaweb2::params::ido_db_host, + $ido_db_host = $::icingaweb2::params::ido_db_host, + $ido_db_name = $::icingaweb2::params::ido_db_name, + $ido_db_pass = $::icingaweb2::params::ido_db_pass, + $ido_db_port = $::icingaweb2::params::ido_db_port, + $ido_db_user = $::icingaweb2::params::ido_db_user, + $ido_type = $::icingaweb2::params::ido_type, + $install_method = $::icingaweb2::params::install_method, + $manage_apache_vhost = $::icingaweb2::params::manage_apache_vhost, + $manage_repo = $::icingaweb2::params::manage_repo, + $pkg_deps = $::icingaweb2::params::pkg_deps, + $pkg_ensure = $::icingaweb2::params::pkg_ensure, + $pkg_list = $::icingaweb2::params::pkg_list, + $web_db = $::icingaweb2::params::web_db, + $web_db_host = $::icingaweb2::params::web_db_host, + $web_db_name = $::icingaweb2::params::web_db_name, + $web_db_pass = $::icingaweb2::params::web_db_pass, + $web_db_port = $::icingaweb2::params::web_db_port, + $web_db_prefix = $::icingaweb2::params::web_db_prefix, + $web_db_user = $::icingaweb2::params::web_db_user, + $web_root = $::icingaweb2::params::web_root, + $web_type = $::icingaweb2::params::web_type, +) inherits icingaweb2::params { + class { 'icingaweb2::preinstall': } -> + class { 'icingaweb2::install': } -> + class { 'icingaweb2::config': } -> + Class [ 'icingaweb2' ] + + validate_absolute_path($config_dir) + validate_absolute_path($web_root) + validate_array($pkg_deps) + validate_array($pkg_list) + validate_bool($config_dir_recurse) + validate_bool($manage_repo) + validate_slength($config_dir_mode, 4) + validate_slength($config_file_mode, 4) + validate_string($config_dir_mode) + validate_string($config_file_mode) + validate_string($config_group) + validate_string($config_user) + validate_string($pkg_ensure) + + validate_re($install_method, + [ + 'git', + 'package', + 'packages', + ] + ) + + validate_re($pkg_ensure, + [ + 'absent', + 'latest', + 'present', + 'purged', + ] + ) +} + diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..5c2466e --- /dev/null +++ b/manifests/install.pp @@ -0,0 +1,29 @@ +# == Class icingaweb2::install +# +class icingaweb2::install { + if $::icingaweb2::install_method == 'package' { + if $::icingaweb2::pkg_list { + package { $::icingaweb2::pkg_list: + ensure => $::icingaweb2::pkg_ensure, + } + } + + if $::icingaweb2::pkg_deps { + package { $::icingaweb2::pkg_deps: + ensure => $::icingaweb2::pkg_ensure, + before => Package[$::icingaweb2::pkg_list], + } + } + } + + if $::icingaweb2::install_method == 'git' { + vcsrepo { 'icingaweb2': + ensure => present, + path => $::icingaweb2::web_root, + provider => 'git', + revision => $::icingaweb2::git_revision, + source => $::icingaweb2::git_repo, + } + } +} + diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..1c4a894 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,59 @@ +# == Class icingaweb2::params +# +class icingaweb2::params { + $git_repo = 'https://git.icinga.org/icingaweb2.git' + $git_revision = undef + $install_method = 'git' + $manage_apache_vhost = false + $manage_repo = false + + $ido_db = 'mysql' + $ido_db_host = 'localhost' + $ido_db_name = 'icingaweb2' + $ido_db_pass = 'icingaweb2' + $ido_db_port = '3306' + $ido_db_user = 'icingaweb2' + $ido_type = 'db' + + $web_type = 'db' + $web_db_host = 'localhost' + $web_db_name = 'icingaweb2' + $web_db_pass = 'icingaweb2' + $web_db_port = '3306' + $web_db_prefix = 'icingaweb2_' + $web_db = 'mysql' + $web_db_user = 'icingaweb2' + + case $::osfamily { + 'RedHat': { + $config_dir = '/etc/icingaweb2' + $config_dir_mode = '0755' + $config_dir_recurse = false + $config_group = 'root' + $config_mode = '0644' + $config_user = 'root' + $pkg_deps = [] + $pkg_ensure = present + $pkg_list = [] + $web_root = '/usr/share/icingaweb2' + } + + 'Debian': { + $config_dir = '/etc/icingaweb2' + $config_dir_mode = '0755' + $config_dir_recurse = false + $config_file_mode = '0644' + $config_group = 'root' + $config_user = 'root' + $pkg_deps = [] + $pkg_ensure = present + $pkg_list = [] + $web_root = '/usr/share/icingaweb2' + } + + default: { + fail "Operating system ${::operatingsystem} is not supported." + } + } +} + diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..4901c9f --- /dev/null +++ b/metadata.json @@ -0,0 +1,71 @@ +{ + "name": "arioch-icingaweb2", + "version": "0.0.0", + "author": "Tom De Vylder", + "summary": "", + "license": "Apache-2.0", + "source": "", + "project_page": "", + "issues_url": "", + "description": "This module install IcingaWeb2", + "tags": [ + "icinga", + "icinga2", + "icingaweb2", + "ido", + "idoutils", + "monitoring", + "mysql", + "nagios", + "postgresql" + ], + "operatingsystem_support": [ + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6.0", + "6.1", + "6.2", + "6.3", + "6.4", + "6.5", + "6.6", + "6.6", + "6.7", + "6.9", + "7.0", + "7.1", + "7.2", + "7.3", + "7.4", + "7.5" + ] + }, + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "6.0", + "6.1", + "6.2", + "6.3", + "6.4", + "6.5" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "6.0", + "6.1", + "6.2", + "6.3", + "6.4", + "6.5" + ] + } + ], + "dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">= 4.0.0"}, + {"name":"puppetlabs/vcsrepo","version_requirement":">= 1.2.0"} + ] +}