File: init.pp

package info (click to toggle)
puppet-module-gnocchi 25.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,096 kB
  • sloc: ruby: 2,339; python: 38; makefile: 10; sh: 10
file content (109 lines) | stat: -rw-r--r-- 3,907 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# == Class: gnocchi
#
# Full description of class gnocchi here.
#
# === Parameters
#
# [*package_ensure*]
#   (optional) The state of gnocchi packages
#   Defaults to 'present'
#
# [*coordination_url*]
#   (optional) The url to use for distributed group membership coordination.
#   Defaults to $facts['os_service_default'].
#
# [*purge_config*]
#   (optional) Whether to set only the specified config options
#   in the gnocchi config.
#   Defaults to false.
#
class gnocchi (
  $package_ensure                    = 'present',
  $coordination_url                  = $facts['os_service_default'],
  $coordination_url_metricd          = $facts['os_service_default'],
  Boolean $purge_config              = false,
  Boolean $use_multiple_config_files = false,
) inherits gnocchi::params {

  include gnocchi::deps

  if $use_multiple_config_files {
    package { 'gnocchi':
      ensure => $package_ensure,
      name   => $::gnocchi::params::common_package_name,
      tag    => ['openstack', 'gnocchi-package'],
    }
    ~> exec { 'copy /etc/gnocchi/gnocchi-metricd.conf':
      command => '/usr/bin/cp /usr/share/gnocchi-common/gnocchi.conf /etc/gnocchi/gnocchi-metricd.conf && /usr/bin/chown root:gnocchi /etc/gnocchi/gnocchi-metricd.conf && /usr/bin/chmod 640 /etc/gnocchi/gnocchi-metricd.conf',
      creates => '/etc/gnocchi/gnocchi-metricd.conf',
    }
    ~> exec { 'copy /etc/gnocchi/gnocchi-api.conf':
      command => '/usr/bin/cp /usr/share/gnocchi-common/gnocchi.conf /etc/gnocchi/gnocchi-api.conf && /usr/bin/chown root:gnocchi /etc/gnocchi/gnocchi-api.conf && /usr/bin/chmod 640 /etc/gnocchi/gnocchi-api.conf',
      creates => '/etc/gnocchi/gnocchi-api.conf',
    }
  } else {
    package { 'gnocchi':
      ensure => $package_ensure,
      name   => $::gnocchi::params::common_package_name,
      tag    => ['openstack', 'gnocchi-package'],
    }
    ~> file{ '/etc/gnocchi/gnocchi-api.conf':
      ensure => absent,
    }
    ~> file{ '/etc/gnocchi/gnocchi-metricd.conf':
      ensure => absent,
    }
  }

  resources { 'gnocchi_config':
    purge => $purge_config,
  }

  if $use_multiple_config_files == true {
    oslo::coordination{ 'gnocchi_api_config':
      backend_url   => $coordination_url,
      manage_config => false,
    }
    gnocchi_api_config {
      'DEFAULT/coordination_url' : value => $coordination_url, secret => true;
    }
    # all coordination settings should be applied and all packages should be
    # installed before service startup
    Oslo::Coordination['gnocchi_api_config'] -> Anchor['gnocchi::service::begin']

    oslo::coordination{ 'gnocchi_metricd_config':
      backend_url   => $coordination_url_metricd,
      manage_config => false,
    }
    gnocchi_metricd_config {
      'DEFAULT/coordination_url' : value => $coordination_url_metricd, secret => true;
    }
    # all coordination settings should be applied and all packages should be
    # installed before service startup
    Oslo::Coordination['gnocchi_metricd_config'] -> Anchor['gnocchi::service::begin']

    oslo::coordination{ 'gnocchi_config':
      backend_url   => $facts['os_service_default'],
      manage_config => false,
    }
    gnocchi_config {
      'DEFAULT/coordination_url' : value => $facts['os_service_default'], secret => true;
    }
    # all coordination settings should be applied and all packages should be
    # installed before service startup
    Oslo::Coordination['gnocchi_config'] -> Anchor['gnocchi::service::begin']

  } else {
    oslo::coordination{ 'gnocchi_config':
      backend_url   => $coordination_url,
      manage_config => false,
    }
    gnocchi_config {
      'DEFAULT/coordination_url' : value => $coordination_url, secret => true;
    }
    # all coordination settings should be applied and all packages should be
    # installed before service startup
    Oslo::Coordination['gnocchi_config'] -> Anchor['gnocchi::service::begin']
  }

}