diff --git a/manifests/deps.pp b/manifests/deps.pp new file mode 100644 index 00000000..e73e4537 --- /dev/null +++ b/manifests/deps.pp @@ -0,0 +1,39 @@ +# +# Copyright (C) 2018 Binero +# +# Author: Tobias Urdin +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: horizon::deps +# +# Horizon anchors and dependency management +# +class horizon::deps { + + anchor { 'horizon::install::begin': } + -> Package<| tag == 'horizon-package' |> + ~> anchor { 'horizon::install::end': } + -> anchor { 'horizon::config::begin': } + ~> anchor { 'horizon::config::end': } + -> anchor { 'horizon::compress::begin': } + -> Exec<| tag == 'horizon-compress' |> + ~> anchor { 'horizon::compress::end': } + -> anchor { 'horizon::service::begin': } + -> Service<| title == 'httpd' |> + ~> anchor { 'horizon::service::end': } + + # Installation or config changes will always restart services. + Anchor['horizon::install::end'] ~> Anchor['horizon::service::begin'] + Anchor['horizon::config::end'] ~> Anchor['horizon::service::begin'] +} diff --git a/manifests/init.pp b/manifests/init.pp index d52ada1a..bb0dcf8a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -526,6 +526,8 @@ class horizon( $tuskar_ui_deployment_mode = undef, ) inherits ::horizon::params { + include ::horizon::deps + $hypervisor_defaults = { 'can_set_mount_point' => true, 'can_set_password' => false, @@ -612,7 +614,7 @@ settings_local.py and parameter server_aliases for setting ServerAlias directive if $cache_backend =~ /MemcachedCache/ { ensure_resources('package', { 'python-memcache' => { name => $::horizon::params::memcache_package, - tag => ['openstack']}}) + tag => ['openstack', 'horizon-package']}}) } package { 'horizon': @@ -625,7 +627,7 @@ settings_local.py and parameter server_aliases for setting ServerAlias directive mode => '0640', owner => $::horizon::params::wsgi_user, group => $::horizon::params::wsgi_group, - require => Package['horizon'], + require => Anchor['horizon::config::begin'], } concat::fragment { 'local_settings.py': @@ -637,13 +639,13 @@ settings_local.py and parameter server_aliases for setting ServerAlias directive exec { 'refresh_horizon_django_cache': command => "${::horizon::params::manage_py} collectstatic --noinput --clear", refreshonly => true, - require => Package['horizon'], + tag => ['horizon-compress'], } exec { 'refresh_horizon_django_compress': command => "${::horizon::params::manage_py} compress --force", refreshonly => true, - require => Package['horizon'], + tag => ['horizon-compress'], } if $compress_offline { diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index 0a87b8c8..df305292 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -115,6 +115,7 @@ class horizon::wsgi::apache ( $root_path = "${::horizon::params::static_path}/openstack-dashboard", ) inherits horizon::params { + include ::horizon::deps include ::apache if $fqdn { @@ -138,7 +139,7 @@ class horizon::wsgi::apache ( # - ${priority}-${vhost_conf_name}.conf # - ${priority}-${vhost_ssl_conf_name}.conf #", - require => Package['horizon'], + require => Anchor['horizon::config::begin'], } @@ -190,7 +191,7 @@ class horizon::wsgi::apache ( group => $unix_group, before => Service['httpd'], mode => '0751', - require => Package['horizon'], + require => Anchor['horizon::config::begin'], } file { "${::horizon::params::logdir}/horizon.log": @@ -199,7 +200,7 @@ class horizon::wsgi::apache ( group => $unix_group, before => Service['httpd'], mode => '0640', - require => [ File[$::horizon::params::logdir], Package['horizon'] ], + require => File[$::horizon::params::logdir], } $script_url = $root_url ? { diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 3350ab49..db0b1799 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -252,7 +252,7 @@ describe 'horizon' do it { is_expected.to contain_package('python-memcache').with( - :tag => ['openstack'] + :tag => ['openstack', 'horizon-package'] ) } end