diff --git a/README.md b/README.md index 689b4a5..9b2e7c6 100644 --- a/README.md +++ b/README.md @@ -1,238 +1,247 @@ [![Build Status](https://travis-ci.org/Icinga/puppet-icingaweb2.png?branch=master)](https://travis-ci.org/Icinga/puppet-icingaweb2) # Icinga Web 2 Puppet Module #### Table of Contents 1. [Overview](#overview) 2. [Module Description - What the module does and why it is useful](#module-description) 3. [Setup - The basics of getting started with Icinga Web 2](#setup) * [What Icinga Web 2 affects](#what-icinga-web-2-affects) 4. [Usage - Configuration options and additional functionality](#usage) 5. [Reference](#reference) 6. [Development - Guide for contributing to the module](#development) ## Overview + [Icinga Web 2] is the associated web interface for the open source monitoring tool [Icinga 2]. This module helps with installing and managing configuration of Icinga Web 2 and its modules on multiple operating systems. ### Description This module installs and configures Icinga Web 2 on your Linux host by using the official packages from [packages.icinga.com]. Dependend packages are installed as they are defined in the Icinga Web 2 package. This module can manage all configurations files of Icinga Web 2 and import an initial database schema. It can install and manage all official [modules](https://www.icinga.com/products/icinga-web-2-modules/) as well as modules developed by the community. +### What's new in version 3.0.0 + +* The current version now uses the `icinga::repos` class from the new module `icinga` for the configuration of +repositories including EPEL on RedHat and Backports on Debian. (see https://github.com/icinga/puppet-icinga) + ## Setup ### What the Icinga 2 Puppet module supports * Installation of Icinga Web 2 via packages * Configuration * MySQL / PostgreSQL database schema import * Install and manage official Icinga Web 2 modules * Install community modules ### Dependencies This module depends on +* [icinga/ciinga] >= 1.0.0 + * needed if `manage_repos` is set to `true` * [puppetlabs/stdlib] >= 4.16.0 * [puppetlabs/vcsrepo] >= 1.3.0 * [puppetlabs/concat] >= 2.0.1 -Depending on your setup the following modules may also be required: - -* [puppetlabs/apt] >= 2.0.0 -* [puppetlabs/yumrepo_core] >= 1.0.0 -* [puppet/zypprepo] >= 2.0.0 - ### Limitations This module has been tested on: * Debian 9, 10 -* CentOS/RHEL 6, 7 +* CentOS/RHEL 6, 7, 8 * Requires [Software Collections Repository](https://wiki.centos.org/AdditionalResources/Repositories/SCL) -* Ubuntu 16.04, 18.04 -* SLES 12 - -* PHP >= 7.0 +* Ubuntu 16.04, 18.04, 20.04 +* SLES 12, 15 Other operating systems or versions may work but have not been tested. ## Usage NOTE: If you plan to use additional modules from git, the CLI `git` command has to be installed. You can manage it yourself as package resource or declare the package name in `extra_packages`. +By default, your distribution's packages are used to install Icinga Web 2. + +Use the `manage_repos` parameter to configure repositories by default the official and stable [packages.icinga.com]. To configure your own +repositories, or use the official testing or nightly snapshot stage, see https://github.com/icinga/puppet-icinga. + +``` puppet +class { '::icingaweb2': + manage_repos => true, +} +``` + The usage of this module isn't simple. That depends on how Icinga Web 2 is implemented. Monitoring is here just a module in a framework. All basic stuff like authentication, logging or authorization is done by this framework. To store user and usergroups in a MySQL database, the database has to exist: ``` mysql::db { 'icingaweb2': user => 'icingaweb2', password => 'supersecret', host => 'localhost', grant => [ 'ALL' ], } class {'icingaweb2': - manage_repo => true, + manage_repos => true, import_schema => true, db_type => 'mysql', db_host => 'localhost', db_port => 3306, db_username => 'icingaweb2', db_password => 'supersecret', config_backend => 'db', extra_packages => [ 'git' ], require => Mysql::Db['icingaweb2'], } ``` If you set `import_schema` to `true` an default admin user `icingaadmin` with password `icinga` will be created automatically and you're allowed to login. In case that `import_schema` is disabled or you'd like to use a different backend for authorization like LDAP, more work is required. At first we need a ressource with credentials to connect a LDAP server: ``` class {'icingaweb2': - manage_repo => true, + manage_repos => true, } icingaweb2::config::resource{ 'my-ldap': type => 'ldap', host => 'localhost', port => 389, ldap_root_dn => 'ou=users,dc=icinga,dc=com', ldap_bind_dn => 'cn=icingaweb2,ou=users,dc=icinga,dc=com', ldap_bind_pw => 'supersecret', } ``` With the help of this resource, we are now creating user and group backends. Users are permitted to login and users and groups will later be used for authorization. ``` icingaweb2::config::authmethod { 'ldap-auth': backend => 'ldap', resource => 'my-ldap', ldap_user_class => 'user', ldap_filter => '(memberof:1.2.840.113556.1.4.1941:=CN=monitoring,OU=groups,DC=icinga,DC=com)', ldap_user_name_attribute => 'cn', order => '05', } icingaweb2::config::groupbackend { 'ldap-groups': backend => 'ldap', resource => 'my-ldap', ldap_group_class => 'group', ldap_group_name_attribute => 'cn', ldap_group_member_attribute => 'member', ldap_base_dn => 'ou=groups,dc=icinga,dc=com', domain => 'icinga.com', } ``` So that a group gets admin rights a role has to manage: ``` icingaweb2::config::role { 'default admin user': groups => 'icingaadmins', permissions => '*', } ``` All available permissions for module monitoring are listed below: | Description | Value | |-------------|-------| | Allow everything | `*` | | Allow to share navigation items | `application/share/navigation` | | Allow to adjust in the preferences whether to show stacktraces | `application/stacktraces` | | Allow to view the application log | `application/log` | | Grant admin permissions, e.g. manage announcements | `admin` | | Allow config access | `config/*` | | Allow access to module doc | `module/doc` | | Allow access to module monitoring | `module/monitoring` | | Allow all commands | `monitoring/command/*` | | Allow scheduling host and service checks | `monitoring/command/schedule-check` | | Allow acknowledging host and service problems | `monitoring/command/acknowledge-problem` | | Allow removing problem acknowledgements | `monitoring/command/remove-acknowledgement` | | Allow adding and deleting host and service comments | `monitoring/command/comment/*` | | Allow commenting on hosts and services | `monitoring/command/comment/add` | | Allow deleting host and service comments | `monitoring/command/comment/delete` | | Allow scheduling and deleting host and service downtimes | `monitoring/command/downtime/*` | | Allow scheduling host and service downtimes | `monitoring/command/downtime/schedule` | | Allow deleting host and service downtimes | `monitoring/command/downtime/delete` | | Allow processing host and service check results | `monitoring/command/process-check-result` | | Allow processing commands for toggling features on an instance-wide basis | `monitoring/command/feature/instance` | | Allow processing commands for toggling features on host and service objects | `monitoring/command/feature/object/*`) | | Allow processing commands for toggling active checks on host and service objects | `monitoring/command/feature/object/active-checks` | | Allow processing commands for toggling passive checks on host and service objects | `monitoring/command/feature/object/passive-checks` | | Allow processing commands for toggling notifications on host and service objects | `monitoring/command/feature/object/notifications` | | Allow processing commands for toggling event handlers on host and service objects | `monitoring/command/feature/object/event-handler` | | Allow processing commands for toggling flap detection on host and service objects | `monitoring/command/feature/object/flap-detection` | | Allow sending custom notifications for hosts and services | `monitoring/command/send-custom-notification` | | Allow access to module setup | `module/setup` | | Allow access to module test | `module/test` | | Allow access to module translation | `module/translation` | Finally we configure the monitoring with the needed connection to the IDO to get information and an API user to send commands to Icinga 2: ``` class {'icingaweb2::module::monitoring': ido_host => 'localhost', ido_db_type => 'mysql', ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', commandtransports => { icinga2 => { transport => 'api', username => 'icingaweb2', password => 'supersecret', } } } ``` ## Reference See [REFERENCE.md](https://github.com/Icinga/puppet-icingaweb2/blob/master/REFERENCE.md) ## Development A roadmap of this project is located at https://github.com/Icinga/puppet-icingaweb2/milestones. Please consider this roadmap when you start contributing to the project. ### Contributing When contributing several steps such as pull requests and proper testing implementations are required. Find a detailed step by step guide in [CONTRIBUTING.md]. ### Testing Testing is essential in our workflow to ensure a good quality. We use RSpec as well as Serverspec to test all components of this module. For a detailed description see [TESTING.md]. ### Release Notes When releasing new versions we refer to [SemVer 1.0.0] for version numbers. All steps required when creating a new release are described in [RELEASE.md] See also [CHANGELOG.md] ### Authors [AUTHORS] is generated on each release. [Icinga 2]: https://www.icinga.com/products/icinga-2/ [Icinga Web 2]: https://www.icinga.com/products/icinga-web-2/ +[icinga/icinga]: https://github.com/icinga/puppet-icinga/ -[puppetlabs/apt]: https://github.com/puppetlabs/puppetlabs-apt -[puppetlabs/yumrepo_core]: https://github.com/puppetlabs/puppetlabs-yumrepo_core -[puppet/zypprepo]: https://forge.puppet.com/puppet/zypprepo [puppetlabs/stdlib]: https://github.com/puppetlabs/puppetlabs-stdlib [puppetlabs/concat]: https://github.com/puppetlabs/puppetlabs-concat [puppetlabs/vcsrepo]: https://forge.puppet.com/puppetlabs/vcsrepo [puppetlabs/mysql]: https://github.com/puppetlabs/puppetlabs-mysql [puppetlabs/puppetlabs-postgresql]: https://github.com/puppetlabs/puppetlabs-postgresql [packages.icinga.com]: https://packages.icinga.com [CHANGELOG.md]: CHANGELOG.md [AUTHORS]: AUTHORS [RELEASE.md]: RELEASE.md [TESTING.md]: TESTING.md [CONTRIBUTING.md]: CONTRIBUTING.md diff --git a/examples/apache2.pp b/examples/apache2.pp index b69eea7..193fe0f 100644 --- a/examples/apache2.pp +++ b/examples/apache2.pp @@ -1,67 +1,67 @@ class { 'apache': mpm_module => 'prefork' } class { 'apache::mod::php': } case $::osfamily { 'redhat': { package { 'php-mysql': } file {'/etc/httpd/conf.d/icingaweb2.conf': source => 'puppet:///modules/icingaweb2/examples/apache2/icingaweb2.conf', require => Class['apache'], notify => Service['httpd'], } package { 'centos-release-scl': before => Class['icingaweb2'] } } 'debian': { class { 'apache::mod::rewrite': } file {'/etc/apache2/conf.d/icingaweb2.conf': source => 'puppet:///modules/icingaweb2/examples/apache2/icingaweb2.conf', require => Class['apache'], notify => Service['apache2'], } } default: { fail("Your plattform ${::osfamily} is not supported by this example.") } } include ::mysql::server mysql::db { 'icingaweb2': user => 'icingaweb2', password => 'icingaweb2', host => 'localhost', grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], } class {'icingaweb2': - manage_repo => true, + manage_repos => true, import_schema => true, db_type => 'mysql', db_host => 'localhost', db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', require => Mysql::Db['icingaweb2'], } class {'icingaweb2::module::monitoring': ido_host => 'localhost', ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', commandtransports => { icinga2 => { transport => 'api', username => 'root', password => 'icinga', } } -} \ No newline at end of file +} diff --git a/examples/import_schema.pp b/examples/import_schema.pp index f98921b..b23873e 100644 --- a/examples/import_schema.pp +++ b/examples/import_schema.pp @@ -1,26 +1,26 @@ include ::mysql::server mysql::db { 'icingaweb2': user => 'icingaweb2', password => 'icingaweb2', host => 'localhost', grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], } include ::postgresql::server postgresql::server::db { 'icingaweb2': user => 'icingaweb2', password => postgresql_password('icingaweb2', 'icingaweb2'), } class {'icingaweb2': - manage_repo => true, + manage_repos => true, import_schema => true, db_type => 'pgsql', db_host => 'localhost', db_port => 5432, db_username => 'icingaweb2', db_password => 'icingaweb2', require => [ Postgresql::Server::Db['icingaweb2'], Mysql::Db['icingaweb2'] ] -} \ No newline at end of file +} diff --git a/examples/init_repo.pp b/examples/init_repos.pp similarity index 50% rename from examples/init_repo.pp rename to examples/init_repos.pp index b43440d..3ecad43 100755 --- a/examples/init_repo.pp +++ b/examples/init_repos.pp @@ -1,3 +1,3 @@ class { 'icingaweb2': - manage_repo => true, + manage_repos => true, } diff --git a/examples/module_director.pp b/examples/module_director.pp index 958e08d..ad67d20 100644 --- a/examples/module_director.pp +++ b/examples/module_director.pp @@ -1,49 +1,49 @@ package { 'git': } include ::mysql::server mysql::db { 'director': user => 'director', password => 'director', host => 'localhost', charset => 'utf8', grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], } class {'icingaweb2': - manage_repo => true, + manage_repos => true, import_schema => true, db_type => 'mysql', db_host => 'localhost', db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', } class {'icingaweb2::module::monitoring': ido_host => 'localhost', ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', commandtransports => { icinga2 => { transport => 'api', username => 'root', password => 'icinga', } } } class {'icingaweb2::module::director': git_revision => 'v1.3.2', db_host => 'localhost', db_name => 'director', db_username => 'director', db_password => 'director', import_schema => true, kickstart => true, endpoint => 'puppet-icingaweb2.localdomain', api_username => 'root', api_password => 'icinga', require => Mysql::Db['director'] -} \ No newline at end of file +} diff --git a/examples/module_monitoring.pp b/examples/module_monitoring.pp index 2c8a5a8..f7b42a3 100644 --- a/examples/module_monitoring.pp +++ b/examples/module_monitoring.pp @@ -1,35 +1,35 @@ include ::mysql::server mysql::db { 'icingaweb2': user => 'icingaweb2', password => 'icingaweb2', host => 'localhost', grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], } class {'icingaweb2': - manage_repo => true, + manage_repos => true, import_schema => true, db_type => 'mysql', db_host => 'localhost', db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', require => Mysql::Db['icingaweb2'], } class {'icingaweb2::module::monitoring': ido_host => 'localhost', ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', protected_customvars => ['*pw*', '*pass*', 'community', 'testabc'], commandtransports => { icinga2 => { transport => 'api', username => 'root', password => 'icinga', } } -} \ No newline at end of file +} diff --git a/examples/nginx.pp b/examples/nginx.pp index 2fa62b3..f0ad435 100644 --- a/examples/nginx.pp +++ b/examples/nginx.pp @@ -1,92 +1,92 @@ # Here is an example nginx resource for use with Slashbunny-phpfpm and the # voxpupuli-nginx module to get icingaweb2 running behind nginx. # $vhost = 'puppet-icingaweb2' include ::nginx nginx::resource::server { 'icingaweb2': server_name => [$vhost], ssl => true, ssl_cert => '/etc/ssl/certs/ssl-cert-snakeoil.pem', ssl_key => '/etc/ssl/private/ssl-cert-snakeoil.key', ssl_redirect => true, index_files => [], use_default_location => false, } nginx::resource::location { 'root': location => '/', server => 'icingaweb2', index_files => [], location_cfg_append => { rewrite => '^/(.*) https://$host/icingaweb2/$1 permanent' } } nginx::resource::location { 'icingaweb2_index': location => '~ ^/icingaweb2/index\.php(.*)$', server => 'icingaweb2', ssl => true, ssl_only => true, index_files => [], fastcgi => '127.0.0.1:9000', fastcgi_index => 'index.php', fastcgi_param => { 'ICINGAWEB_CONFIGDIR' => '/etc/icingaweb2', 'REMOTE_USER' => '$remote_user', 'SCRIPT_FILENAME' => '/usr/share/icingaweb2/public/index.php', }, } nginx::resource::location { 'icingaweb': location => '~ ^/icingaweb2(.+)?', location_alias => '/usr/share/icingaweb2/public', try_files => ['$1', '$uri', '$uri/', '/icingaweb2/index.php$is_args$args'], index_files => ['index.php'], server => 'icingaweb2', ssl => true, ssl_only => true, } class { 'phpfpm': poold_purge => true, } phpfpm::pool { 'main': } include ::mysql::server mysql::db { 'icingaweb2': user => 'icingaweb2', password => 'icingaweb2', host => 'localhost', grant => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE VIEW', 'CREATE', 'INDEX', 'EXECUTE', 'ALTER', 'REFERENCES'], } class {'icingaweb2': - manage_repo => true, + manage_repos => true, import_schema => true, db_type => 'mysql', db_host => 'localhost', db_port => 3306, db_username => 'icingaweb2', db_password => 'icingaweb2', conf_user => 'nginx', require => Mysql::Db['icingaweb2'], } class {'icingaweb2::module::monitoring': ido_host => 'localhost', ido_db_name => 'icinga2', ido_db_username => 'icinga2', ido_db_password => 'supersecret', commandtransports => { icinga2 => { transport => 'api', username => 'root', password => 'icinga', } } } diff --git a/examples/resource.pp b/examples/resource.pp index 8a25881..ed6519c 100644 --- a/examples/resource.pp +++ b/examples/resource.pp @@ -1,22 +1,22 @@ class { 'icingaweb2': - manage_repo => true, + manage_repos => true, } icingaweb2::config::resource{'my-sql': type => 'db', db_type => 'mysql', host => 'localhost', port => 3306, db_name => 'icingaweb2', db_username => 'root', db_password => 'supersecret', } icingaweb2::config::resource{'my-ldap': type => 'ldap', host => 'localhost', port => 389, ldap_root_dn => 'dc=users,dc=icinga,dc=com', ldap_bind_dn => 'cn=root,dc=users,dc=icinga,dc=com', ldap_bind_pw => 'supersecret', } diff --git a/manifests/init.pp b/manifests/init.pp index 1da4743..68092d8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,160 +1,171 @@ # @summary # Installs and configures Icinga Web 2. # # @param [Enum['file', 'syslog', 'php', 'none']] logging # Whether Icinga Web 2 should log to 'file', 'syslog' or 'php' (web server's error log). Setting 'none' disables logging. # # @param [Stdlib::Absolutepath] logging_file # If 'logging' is set to 'file', this is the target log file. # # @param [Enum['ERROR', 'WARNING', 'INFO', 'DEBUG']] logging_level # Logging verbosity. Possible values are 'ERROR', 'WARNING', 'INFO' and 'DEBUG'. # # @param [Pattern[/user|local[0-7]/]] logging_facility # Logging facility when using syslog. Possible values are 'user' or 'local0' up to 'local7'. # # @param [String] logging_application # Logging application name when using syslog. # # @param [Boolean] show_stacktraces # Whether to display stacktraces in the web interface or not. # # @param [Stdlib::Absolutepath] module_path # Path to module sources. Multiple paths must be separated by colon. # # @param [String] theme # The default theme setting. Users may override this settings. # # @param [Boolean] theme_disabled # Whether users can change themes or not. # # @param [Boolean] manage_repo -# When set to true this module will install the packages.icinga.com repository. +# Deprecated, use manage_repos. +# +# @param [Boolean] manage_repos +# When set to true this module will use the module icinga/puppet-icinga to manage repositories, +# e.g. the release repo on packages.icinga.com repository by default, the EPEL repository or Backports. +# For more information, see http://github.com/icinga/puppet-icinga. # # @param [Boolean] manage_package # If set to `false` packages aren't managed. # # @param [Optional[Array[String]]] extra_packages # An array of packages to install additionally. # # @param [Boolean] import_schema # Import database scheme. Make sure you have an existing database if you use this option. # # @param [Enum['mysql', 'pgsql']] db_type # Database type, can be either `mysql` or `pgsql`. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # @param [Stdlib::Host] db_host # Database hostname. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # @param [Stdlib::Port] db_port # Port of database host. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # @param [String] db_name # Database name. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # @param [Optional[String]] db_username # Username for database access. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # @param [Optional[String]] db_password # Password for database access. This parameter is only used if `import_schema` is `true` or # `config_backend` is `db`. # # @param [Enum['ini', 'db']] config_backend # The global Icinga Web 2 preferences can either be stored in a database or in ini files. This parameter can either # be set to `db` or `ini`. # # @param [String] conf_user # By default this module expects Apache2 on the server. You can change the owner of the config files with this # parameter. # # @param [String] conf_group # Group membership of config files. # # @param [Optional[String]] default_domain # When using domain-aware authentication, you can set a default domain here. # # @param [Optional[Stdlib::Absolutepath]] cookie_path # Path to where cookies are stored. # # @example Use MySQL as backend for user authentication: # include ::mysql::server # # mysql::db { 'icingaweb2': # user => 'icingaweb2', # password => 'supersecret', # host => 'localhost', # grant => [ 'ALL' ], # } # # class {'icingaweb2': -# manage_repo => true, +# manage_repos => true, # import_schema => true, # db_type => 'mysql', # db_host => 'localhost', # db_port => 3306, # db_username => 'icingaweb2', # db_password => 'supersecret', # require => Mysql::Db['icingaweb2'], # } # # @example Use PostgreSQL as backend for user authentication: # include ::postgresql::server # # postgresql::server::db { 'icingaweb2': # user => 'icingaweb2', # password => postgresql_password('icingaweb2', 'icingaweb2'), # } # # class {'icingaweb2': -# manage_repo => true, +# manage_repos => true, # import_schema => true, # db_type => 'pgsql', # db_host => 'localhost', # db_port => 5432, # db_username => 'icingaweb2', # db_password => 'icingaweb2', # require => Postgresql::Server::Db['icingaweb2'], # } # class icingaweb2 ( Stdlib::Absolutepath $module_path, Stdlib::Absolutepath $logging_file, String $conf_user, String $conf_group, Enum['file', 'syslog', 'php', 'none'] $logging = 'file', Enum['ERROR', 'WARNING', 'INFO', 'DEBUG'] $logging_level = 'INFO', Pattern[/user|local[0-7]/] $logging_facility = 'user', String $logging_application = 'icingaweb2', Boolean $show_stacktraces = false, String $theme = 'Icinga', Boolean $theme_disabled = false, Boolean $manage_repo = false, + Boolean $manage_repos = false, Boolean $manage_package = true, Optional[Array[String]] $extra_packages = undef, Boolean $import_schema = false, Enum['mysql', 'pgsql'] $db_type = 'mysql', Stdlib::Host $db_host = 'localhost', Stdlib::Port $db_port = 3306, String $db_name = 'icingaweb2', Optional[String] $db_username = undef, Optional[String] $db_password = undef, Enum['ini', 'db'] $config_backend = 'ini', Optional[String] $default_domain = undef, Optional[Stdlib::Absolutepath] $cookie_path = undef, ) { require ::icingaweb2::globals - class { '::icingaweb2::repo': } - -> class { '::icingaweb2::install': } + if $manage_repos or $manage_repo { + require ::icinga::repos + if $manage_repo { + deprecation('manage_repo', 'manage_repo is deprecated and will be replaced by manage_repos in the future.') + } + } + + class { '::icingaweb2::install': } -> class { '::icingaweb2::config': } - contain ::icingaweb2::repo contain ::icingaweb2::install contain ::icingaweb2::config } diff --git a/manifests/repo.pp b/manifests/repo.pp deleted file mode 100644 index 59a3c41..0000000 --- a/manifests/repo.pp +++ /dev/null @@ -1,95 +0,0 @@ -# @summary -# Manages the packages.icinga.com repository based on the operating system. -# -# @api private -# -class icingaweb2::repo { - - assert_private("You're not supposed to use this defined type manually.") - - if $::icingaweb2::manage_repo and $::icingaweb2::manage_package { - - case $::facts['os']['family'] { - 'redhat': { - case $::facts['os']['name'] { - 'centos', 'redhat': { - yumrepo { 'icinga-stable-release': - baseurl => "http://packages.icinga.com/epel/${::facts['os']['release']['major']}/release/", - descr => 'ICINGA (stable release for epel)', - enabled => 1, - gpgcheck => 1, - gpgkey => 'http://packages.icinga.com/icinga.key', - } - } - default: { - fail('Your plattform is not supported to manage a repository.') - } - } - } - 'debian': { - case $::facts['os']['name'] { - 'debian': { - include ::apt, ::apt::backports - apt::source { 'icinga-stable-release': - location => 'http://packages.icinga.com/debian', - release => "icinga-${::facts['lsbdistcodename']}", - repos => 'main', - key => { - id => 'F51A91A5EE001AA5D77D53C4C6E319C334410682', - source => 'http://packages.icinga.com/icinga.key', - }; - } - } - 'ubuntu': { - include ::apt - apt::source { 'icinga-stable-release': - location => 'http://packages.icinga.com/ubuntu', - release => "icinga-${::facts['lsbdistcodename']}", - repos => 'main', - key => { - id => 'F51A91A5EE001AA5D77D53C4C6E319C334410682', - source => 'http://packages.icinga.com/icinga.key', - }; - } - } - default: { - fail('Your plattform is not supported to manage a repository.') - } - } - contain ::apt::update - } - 'suse': { - - file { '/etc/pki/GPG-KEY-icinga': - ensure => present, - source => 'http://packages.icinga.com/icinga.key', - } - - exec { 'import icinga gpg key': - path => '/bin:/usr/bin:/sbin:/usr/sbin', - command => 'rpm --import /etc/pki/GPG-KEY-icinga', - unless => 'rpm -q gpg-pubkey-`echo $(gpg --throw-keyids < /etc/pki/GPG-KEY-icinga) | cut --characters=11-18 | tr [A-Z] [a-z]', - require => File['/etc/pki/GPG-KEY-icinga'], - logoutput => 'on_failure', - } - - case $::facts['os']['name'] { - 'SLES': { - zypprepo { 'icinga-stable-release': - baseurl => "http://packages.icinga.com/SUSE/${::facts['os']['release']['full']}/release/", - enabled => 1, - gpgcheck => 1, - require => Exec['import icinga gpg key'] - } - } - default: { - fail('Your plattform is not supported to manage a repository.') - } - } - } - default: { - fail('Your plattform is not supported to manage a repository.') - } - } - } # if $::icinga::manage_repo -} diff --git a/metadata.json b/metadata.json index 2d53921..20dbbbc 100644 --- a/metadata.json +++ b/metadata.json @@ -1,81 +1,87 @@ { "name": "icinga-icingaweb2", "version": "2.4.1", "author": "Icinga Team", "summary": "Icinga Web 2 Puppet Module", "license": "Apache-2.0", "source": "git://github.com/Icinga/puppet-icingaweb2", "project_page": "https://github.com/Icinga/puppet-icingaweb2", "issues_url": "https://github.com/Icinga/puppet-icingaweb2/issues", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.16.0 < 7.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 2.0.1 < 7.0.0" }, + { + "name": "icinga/icinga", + "version_requirement": ">= 1.0.0 < 2.0.0" + }, { "name": "puppetlabs/vcsrepo", "version_requirement": ">= 1.3.0 < 4.0.0" }, { "name": "camptocamp/systemd", "version_requirement": ">= 1.1.1 < 3.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "Debian", "operatingsystemrelease": [ "9", "10" ] }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7", "8" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7", "8" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "16.04", - "18.04" + "18.04", + "20.04" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ - "12" + "12", + "15" ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 4.7.0 < 7.0.0" } ], "tags": [ "icinga", "icinga2", "icingaweb2", "monitoring" ], "pdk-version": "1.18.1", "template-url": "pdk-default#1.18.1", "template-ref": "tags/1.18.1-0-g3d2e75c" } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 8e90782..e912bdb 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,38 +1,28 @@ require 'spec_helper' describe 'icingaweb2', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do let :facts do facts end let(:conf_dir) { '/etc/icingaweb2' } context 'with all default parameters' do it { is_expected.to compile } it { is_expected.to contain_class('icingaweb2::config') } it { is_expected.to contain_class('icingaweb2::install') } - it { is_expected.to contain_class('icingaweb2::repo') } it { is_expected.to contain_package('icingaweb2').with('ensure' => 'installed') } - case facts[:osfamily] - when 'Debian' - it { is_expected.not_to contain_apt__source('icinga-stable-release') } - when 'RedHat' - it { is_expected.not_to contain_yumrepo('icinga-stable-release') } - when 'Suse' - it { is_expected.not_to contain_zypprepo('icinga-stable-release') } - end - context "#{os} with manage_package => false" do let(:params) { { manage_package: false } } it { is_expected.not_to contain_package('icinga2').with('ensure' => 'installed') } end end end end end diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb deleted file mode 100644 index aa0852c..0000000 --- a/spec/classes/repo_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'spec_helper' - -describe('icingaweb2::repo', type: :class) do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with manage_repo => true' do - let :pre_condition do - "class { 'icingaweb2': manage_repo => true}" - end - - case facts[:osfamily] - when 'Debian' - it { is_expected.to contain_apt__source('icinga-stable-release') } - when 'RedHat' - it { is_expected.to contain_yumrepo('icinga-stable-release') } - when 'Suse' - it { is_expected.to contain_zypprepo('icinga-stable-release') } - end - end - - context 'with manage_repo => false' do - let :pre_condition do - "class { 'icingaweb2': manage_repo => false}" - end - - it { is_expected.not_to contain_apt__source('icinga-stable-release') } - it { is_expected.not_to contain_yumrepo('icinga-stable-release') } - it { is_expected.not_to contain_zypprepo('icinga-stable-release') } - end - end - end -end