File: dashboard.pp

package info (click to toggle)
puppet-module-murano 23.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 928 kB
  • sloc: ruby: 2,856; python: 38; sh: 10; makefile: 10
file content (150 lines) | stat: -rw-r--r-- 4,243 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# == Class: murano::dashboard
#
#  murano dashboard package
#
# === Parameters
#
# [*package_ensure*]
#  (Optional) Ensure state for package
#  Defaults to 'present'
#
# [*dashboard_name*]
#  (Optional) Overrides the default dashboard name (Murano) that is displayed
#  in the main accordion navigation
#  Defaults to 'undef'
#
# [*repo_url*]
#  (Optional) Application repository URL for murano-dashboard
#  Defaults to 'undef'
#
# [*enable_glare*]
#  (Optional) Whether Murano to use Glare API (ex Glance v3 API)
#  Defaults to false
#
# [*collect_static_script*]
#  (Optional) Path to horizon manage utility
#  Defaults to '/usr/share/openstack-dashboard/manage.py'
#
# [*metadata_dir*]
#  (Optional) Directory to store murano dashboard metadata cache
#  Defaults to '/var/cache/murano-dashboard'
#
# [*max_file_size*]
#  (Optional) Maximum allowed filesize to upload
#  Defaults to '5'
#
# [*dashboard_debug_level*]
#  (Optional) Murano dashboard logging level
#  Defaults to 'DEBUG'
#
# [*client_debug_level*]
#  (Optional) Murano client logging level
#  Defaults to 'ERROR'
#
# [*sync_db*]
#  (Optional) Whether to sync database
#  Default to 'true'
#
# [*log_handler*]
#  (Optional) Log handler.
#  Defaults to 'file'
#
# [*image_filter_project_id*]
#  (Optional) Filter image list by project ID
#  Defaults to 'undef'
#
class murano::dashboard(
  $package_ensure          = 'present',
  $dashboard_name          = undef,
  $repo_url                = undef,
  Boolean $enable_glare    = false,
  $collect_static_script   = '/usr/share/openstack-dashboard/manage.py',
  $metadata_dir            = '/var/cache/murano-dashboard',
  $max_file_size           = '5',
  $dashboard_debug_level   = 'DEBUG',
  $client_debug_level      = 'ERROR',
  $log_handler             = 'file',
  Boolean $sync_db         = true,
  $image_filter_project_id = undef,
) {

  include murano::deps
  include murano::params

  include apache::params

  package { 'murano-dashboard':
    ensure => $package_ensure,
    name   => $::murano::params::dashboard_package_name,
    tag    => ['openstack', 'murano-packages'],
  }

  concat { $::murano::params::local_settings_path: }

  concat::fragment { 'original_config':
    target => $::murano::params::local_settings_path,
    source => $::murano::params::local_settings_path,
    order  => 1,
  }

  concat::fragment { 'murano_dashboard_section':
    target  => $::murano::params::local_settings_path,
    content => template('murano/local_settings.py.erb'),
    order   => 2,
  }

  exec { 'clean_horizon_config':
    command => "sed -e '/^## MURANO_CONFIG_BEGIN/,/^## MURANO_CONFIG_END ##/ d' -i ${::murano::params::local_settings_path}",
    onlyif  => "grep '^## MURANO_CONFIG_BEGIN' ${::murano::params::local_settings_path}",
    path    => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ],
  }

  if $facts['os']['name'] == 'Ubuntu' {
    $collect_static_command = "${collect_static_script} collectstatic --noinput"
  } else {
    $collect_static_command = "${collect_static_script} collectstatic --noinput --clear"
  }

  exec { 'django_collectstatic':
    command     => $collect_static_command,
    environment => [
      "APACHE_USER=${::apache::params::user}",
      "APACHE_GROUP=${::apache::params::group}",
    ],
    refreshonly => true,
  }

  exec { 'django_compressstatic':
    command     => "${collect_static_script} compress --force",
    environment => [
      "APACHE_USER=${::apache::params::user}",
      "APACHE_GROUP=${::apache::params::group}",
    ],
    refreshonly => true,
  }

  if $sync_db {
    exec { 'django_syncdb':
      command     => "${collect_static_script} migrate --noinput",
      environment => [
        "APACHE_USER=${::apache::params::user}",
        "APACHE_GROUP=${::apache::params::group}",
      ],
      refreshonly => true,
    }

    Exec['django_compressstatic']
      ~> Exec['django_syncdb']
        ~> Service <| title == 'httpd' |>
  }

  Package['murano-dashboard']
    -> Exec['clean_horizon_config']
      -> Concat[$::murano::params::local_settings_path]
        -> Service <| title == 'httpd' |>

  Package['murano-dashboard']
    ~> Exec['django_collectstatic']
      ~> Exec['django_compressstatic']
        ~> Service <| title == 'httpd' |>
}