Skip to content

Commit

Permalink
use hiera for service class osfamily if statements
Browse files Browse the repository at this point in the history
this should give some more flexibility in the future.
  • Loading branch information
trefzer committed Nov 22, 2021
1 parent 1639137 commit 576f607
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
5 changes: 5 additions & 0 deletions data/Debian-family.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# Defaults for Debian os family (eg. Debian, Ubuntu etc)

prosody::service::hasstatus: ~
prosody::service::restart: ~
5 changes: 5 additions & 0 deletions data/OpenBSD-family.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# Defaults for OpenBSD os family

prosody::service::hasstatus: ~
prosody::service::restart: ~
3 changes: 3 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ prosody::community_modules::ensure: present
prosody::community_modules::path: /var/lib/prosody/modules
prosody::community_modules::source: https://hg.prosody.im/prosody-modules/
prosody::community_modules::type: hg

prosody::service::hasstatus: false
prosody::service::restart: '/usr/bin/prosodyctl reload'
3 changes: 3 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ hierarchy:
- name: "osname"
paths:
- "os/%{facts.os.name}.yaml"
- name: "osfamily"
paths:
- "%{facts.os.family}-family.yaml"
- name: common
path: common.yaml
35 changes: 11 additions & 24 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
# == Class: prosody::service
class prosody::service {
class prosody::service(
Optional[Boolean] $hasstatus = undef,
Optional[String] $restart = undef,
) {

if $prosody::daemonize {
case $facts['os']['family'] {
'OpenBSD': {
service { 'prosody':
ensure => running,
enable => true,
require => Class[prosody::config],
}
}
'Debian': {
service { 'prosody':
ensure => running,
enable => true,
require => Class[prosody::config],
}
}
default: {
service { 'prosody' :
ensure => running,
hasstatus => false,
restart => '/usr/bin/prosodyctl reload',
require => Class[prosody::config],
}
}
service { 'prosody':
ensure => running,
enable => true,
hasstatus => $hasstatus,
restart => $restart,
require => Class[prosody::config],
}
}
}

0 comments on commit 576f607

Please sign in to comment.