Skip to content

Commit

Permalink
Merge pull request #32 from ekohl/update-module
Browse files Browse the repository at this point in the history
Drop Ubuntu 14.04, use more data types and drop UNSET defaults
  • Loading branch information
bastelfreak committed Dec 1, 2019
2 parents 0c94805 + 8dcd7f9 commit 3bab086
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 204 deletions.
1 change: 0 additions & 1 deletion .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
docker_sets:
- set: debian8-64
- set: debian9-64
- set: ubuntu1404-64
- set: ubuntu1604-64
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ matrix:
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=debian9-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_debug=true BEAKER_setfile=ubuntu1404-64 BEAKER_HYPERVISOR=docker CHECK=beaker
services: docker
- rvm: 2.5.3
bundler_args: --without development release
env: PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=ubuntu1604-64 BEAKER_HYPERVISOR=docker CHECK=beaker
Expand Down
267 changes: 117 additions & 150 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,206 +1,173 @@
# == Class: bird
# @summary Install and configure bird
# @author Sebastien Badia <http://sebastien.badia.fr/>
# @author Lorraine Data Network <http://ldn-fai.net/>
#
# Install and configure bird
#
# === Parameters
#
# [*config_file_v4*]
# @param config_file_v4
# Bird configuration file for IPv4.
# Default: UNSET. (this value is a puppet source, example 'puppet:///modules/bgp/bird.conf').
#
# [*config_template_v4*]
# Bird configuration template for IPv4.
# Default: UNSET. (this value is a template source, it will be passed into the template() function).
# @param config_template_v4
# Bird configuration template for IPv4. This value is a template source, it
# will be passed into the template() function.
#
# [*daemon_name_v6*]
# The service name used by puppet ressource
# Default: bird6
# @param daemon_name_v6
# The service name used by puppet resource
#
# [*package_name_v6*]
# The package name used by puppet ressource
# Default: bird6
# @param package_name_v6
# The package name used by puppet resource
#
# [*daemon_name_v4*]
# The service name used by puppet ressource
# Default: bird
# @param daemon_name_v4
# The service name used by puppet resource
#
# [*package_name_v4*]
# The package name used by puppet ressource
# Default: bird
# @param package_name_v4
# The package name used by puppet resource
#
# [*config_path_v6*]
# @param config_path_v6
# The full path of the v6 configuration file
# Default: /etc/bird/bird6.conf
#
# [*config_path_v4*]
# @param config_path_v4
# The full path of the v4 configuration file
# Default: /etc/bird/bird.conf
#
# [*enable_v6*]
# @param enable_v6
# Boolean for enable IPv6 (install bird6 package)
# Default: false
#
# [*manage_conf*]
# @param manage_conf
# Boolean, global parameter to disable or enable mangagment of bird configuration files.
# Default: false
#
# [*manage_service*]
# @param manage_service
# Boolean, global parameter to disable or enable mangagment of bird service.
# Default: false
#
# [*service_v6_ensure*]
# @param service_v6_ensure
# Bird IPv6 daemon ensure (shoud be running or stopped).
# Default: running
#
# [*service_v6_enable*]
# @param service_v6_enable
# Boolean, enabled param of Bird IPv6 service (run at boot time).
# Default: false
#
# [*service_v4_ensure*]
# @param service_v4_ensure
# Bird IPv4 daemon ensure (shoud be running or stopped).
# Default: running
#
# [*service_v4_enable*]
# @param service_v4_enable
# Boolean, enabled param of Bird IPv4 service (run at boot time).
# Default: false
#
# [*config_file_v6*]
# @param config_file_v6
# Bird configuration file for IPv6.
# Default: UNSET. (this value is a puppet source, example 'puppet:///modules/bgp/bird6.conf').
#
# [*config_template_v6*]
# Bird configuration template for IPv6.
# Default: UNSET. (this value is a template source, it will be passed into the template() function).
#
# === Examples
#
# class { 'bird':
# enable_v6 => true,
# config_file_v4 => 'puppet:///modules/bgp/ldn/bird.conf',
# config_file_v6 => 'puppet:///modules/bgp/ldn/bird6.conf',
# }
# @param config_template_v6
# Bird configuration template for IPv6. This value is a template source, it
# will be passed into the template() function.
#
# === Authors
# @example IPv4 only
# class { 'bird':
# config_file_v4 => 'puppet:///modules/bgp/ldn/bird.conf',
# }
#
# Sebastien Badia <http://sebastien.badia.fr/>
# Lorraine Data Network <http://ldn-fai.net/>
#
# === Copyright
#
# Copyleft 2013 Sebastien Badia
# See LICENSE file
# @example Both IPv4 and IPv6
# class { 'bird':
# enable_v6 => true,
# config_file_v4 => 'puppet:///modules/bgp/ldn/bird.conf',
# config_file_v6 => 'puppet:///modules/bgp/ldn/bird6.conf',
# }
#
class bird (
$daemon_name_v4 = $bird::params::daemon_name_v4,
$package_name_v4 = $bird::params::package_name_v4,
$config_path_v4 = $bird::params::config_path_v4,
$config_file_v4 = 'UNSET',
$config_template_v4 = 'UNSET',
String[1] $daemon_name_v4 = 'bird',
String[1] $package_name_v4 = 'bird',
Stdlib::Absolutepath $config_path_v4 = $bird::params::config_path_v4,
Optional[Stdlib::Filesource] $config_file_v4 = undef,
Optional[String[1]] $config_template_v4 = undef,
Boolean $enable_v6 = false,
Boolean $manage_conf = false,
Boolean $manage_service = false,
Enum['running', 'stopped'] $service_v6_ensure = 'running',
Stdlib::Ensure::Service $service_v6_ensure = 'running',
Boolean $service_v6_enable = false,
Enum['running', 'stopped'] $service_v4_ensure = 'running',
Stdlib::Ensure::Service $service_v4_ensure = 'running',
Boolean $service_v4_enable = false,
$daemon_name_v6 = $bird::params::daemon_name_v6,
$package_name_v6 = $bird::params::package_name_v6,
$config_path_v6 = $bird::params::config_path_v6,
$config_file_v6 = 'UNSET',
$config_template_v6 = 'UNSET',
String[1] $daemon_name_v6 = 'bird6',
String[1] $package_name_v6 = $bird::params::package_name_v6,
Stdlib::Absolutepath $config_path_v6 = $bird::params::config_path_v6,
Optional[Stdlib::Filesource] $config_file_v6 = undef,
Optional[String[1]] $config_template_v6 = undef,
) inherits bird::params {

ensure_packages([$package_name_v4], {'ensure' => 'present'})

if $manage_service == true {
service {
$daemon_name_v4:
ensure => $service_v4_ensure,
enable => $service_v4_enable,
hasrestart => false,
restart => '/usr/sbin/birdc configure',
hasstatus => false,
pattern => $daemon_name_v4,
require => Package[$package_name_v4];
if $manage_service {
service { $daemon_name_v4:
ensure => $service_v4_ensure,
enable => $service_v4_enable,
hasrestart => false,
restart => '/usr/sbin/birdc configure',
hasstatus => false,
pattern => $daemon_name_v4,
require => Package[$package_name_v4];
}
}

if $manage_conf == true {
if $config_file_v4 == 'UNSET' and $config_template_v4 == 'UNSET' {
if $manage_conf {
unless $config_file_v4 or $config_template_v4 {
fail("either config_file_v4 or config_template_v4 parameter must be set (config_file_v4: ${config_file_v4}, config_template_v4: ${config_template_v4})")
}

if $config_file_v4 {
$config_file_v4_content = undef
} else {
if $config_file_v4 != 'UNSET' {
file {
$config_path_v4:
ensure => file,
source => $config_file_v4,
owner => root,
group => root,
mode => '0644',
notify => Service[$daemon_name_v4],
require => Package[$package_name_v4];
}
} else {
file {
$config_path_v4:
ensure => file,
content => template($config_template_v4),
owner => root,
group => root,
mode => '0644',
notify => Service[$daemon_name_v4],
require => Package[$package_name_v4];
}
} # config_file_v4
} # config_tmpl_v4
} # manage_conf
$config_file_v4_content = template($config_template_v4)
}

file { $config_path_v4:
ensure => file,
source => $config_file_v4,
content => $config_file_v4_content,
owner => root,
group => root,
mode => '0644',
require => Package[$package_name_v4];
}

if $enable_v6 == true {
if $manage_service {
File[$config_path_v4] ~> Service[$daemon_name_v4]
}
}

if $enable_v6 {

ensure_packages([$package_name_v6], {'ensure' => 'present'})

if $manage_service == true {
service {
$daemon_name_v6:
ensure => $service_v6_ensure,
enable => $service_v6_enable,
hasrestart => false,
restart => '/usr/sbin/birdc6 configure',
hasstatus => false,
pattern => $daemon_name_v6,
require => Package[$package_name_v6];
if $manage_service {
service { $daemon_name_v6:
ensure => $service_v6_ensure,
enable => $service_v6_enable,
hasrestart => false,
restart => '/usr/sbin/birdc6 configure',
hasstatus => false,
pattern => $daemon_name_v6,
require => Package[$package_name_v6];
}
}

if $manage_conf == true {
if $config_file_v6 == 'UNSET' and $config_template_v6 == 'UNSET' {
if $manage_conf {
unless $config_file_v6 or $config_template_v6 {
fail("either config_file_v6 or config_template_v6 parameter must be set (config_file_v6: ${config_file_v6}, config_template_v6: ${config_template_v6})")
}

if $config_file_v6 {
$config_file_v6_content = undef
} else {
if $config_file_v6 != 'UNSET' {
file {
$config_path_v6:
ensure => file,
source => $config_file_v6,
owner => root,
group => root,
mode => '0644',
notify => Service[$daemon_name_v6],
require => Package[$package_name_v6];
}
} else {
file {
$config_path_v6:
ensure => file,
content => template($config_template_v6),
owner => root,
group => root,
mode => '0644',
notify => Service[$daemon_name_v6],
require => Package[$package_name_v6];
}
} # config_file_v6
} # config_tmpl_v6
} # manage_conf
} # enable_v6
$config_file_v6_content = template($config_template_v6)
}

file { $config_path_v6:
ensure => file,
source => $config_file_v6,
content => $config_file_v6_content,
owner => root,
group => root,
mode => '0644',
require => Package[$package_name_v6];
}

if $manage_service {
File[$config_path_v6] ~> Service[$daemon_name_v6]
}
}
}

} # Class:: bird
}
19 changes: 6 additions & 13 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# Class:: bird::params
#
# @summary OS dependent parameters
# @api private
class bird::params {
case $facts['os']['family'] {
'Debian': {
$config_path_v4 = '/etc/bird/bird.conf'
$config_path_v6 = '/etc/bird/bird6.conf'
$daemon_name_v4 = 'bird'
$daemon_name_v6 = 'bird6'
$package_name_v4 = 'bird'
# Compatibility for Debian oldstable and Ubuntu old LTS
# Compatibility Debian oldoldstable
# the bird package now provides bird and bird6 daemons
if ($facts['os']['name'] == 'ubuntu' and $facts['lsbdistcodename'] in ['precise', 'trusty']) or
($facts['os']['name'] == 'debian' and $facts['os']['release']['major'] in ['7', '8']) {
if $facts['os']['name'] == 'debian' and $facts['os']['release']['major'] == '8' {
$package_name_v6 = 'bird6'
} else {
$package_name_v6 = 'bird'
Expand All @@ -20,13 +16,10 @@
'RedHat': {
$config_path_v4 = '/etc/bird.conf'
$config_path_v6 = '/etc/bird6.conf'
$daemon_name_v4 = 'bird'
$daemon_name_v6 = 'bird6'
$package_name_v4 = 'bird'
$package_name_v6 = 'bird6'
}
default: {
fail("Unsupported osfamily: ${facts['os']['family']}")
}
} # Case $::operatingsystem
} # Class:: bird::params
}
}
3 changes: 1 addition & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04",
"16.04"
]
}
Expand All @@ -27,7 +26,7 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 6.0.0"
"version_requirement": ">= 4.25.0 < 7.0.0"
}
],
"requirements": [
Expand Down
Loading

0 comments on commit 3bab086

Please sign in to comment.