diff --git a/manifests/api.pp b/manifests/api.pp index ae4d6dd..e7948a3 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -32,12 +32,10 @@ class murano::api( $port = $::os_service_default, ) { + include ::murano::deps include ::murano::params include ::murano::policy - Murano_config<||> ~> Service['murano-api'] - Class['murano::policy'] -> Service['murano-api'] - if $manage_service { if $enabled { $service_ensure = 'running' @@ -58,14 +56,10 @@ class murano::api( } service { 'murano-api': - ensure => $service_ensure, - name => $::murano::params::api_service_name, - enable => $enabled, - require => Package['murano-api'], - tag => 'murano-service', + ensure => $service_ensure, + name => $::murano::params::api_service_name, + enable => $enabled, + tag => 'murano-service', } - Package['murano-api'] ~> Service['murano-api'] - Murano_paste_ini_config<||> ~> Service['murano-api'] - } diff --git a/manifests/application.pp b/manifests/application.pp index fa1154f..70fc8a1 100644 --- a/manifests/application.pp +++ b/manifests/application.pp @@ -35,6 +35,8 @@ define murano::application ( $public = true, ) { + include ::murano::deps + $package_path="/var/cache/murano/meta/${package_name}.zip" murano_application { $package_name: diff --git a/manifests/cfapi.pp b/manifests/cfapi.pp index fd603e1..24a9dc3 100644 --- a/manifests/cfapi.pp +++ b/manifests/cfapi.pp @@ -41,12 +41,10 @@ class murano::cfapi( $auth_url = 'http://127.0.0.1:5000', ) { + include ::murano::deps include ::murano::params include ::murano::policy - Murano_cfapi_config<||> ~> Service['murano-cfapi'] - Class['murano::policy'] -> Service['murano-cfapi'] - if $manage_service { if $enabled { $service_ensure = 'running' @@ -69,13 +67,10 @@ class murano::cfapi( } service { 'murano-cfapi': - ensure => $service_ensure, - name => $::murano::params::cfapi_service_name, - enable => $enabled, - require => Package['murano-cfapi'], - tag => 'murano-service', + ensure => $service_ensure, + name => $::murano::params::cfapi_service_name, + enable => $enabled, + tag => 'murano-service', } - Package['murano-cfapi'] ~> Service['murano-cfapi'] - Murano_cfapi_paste_ini_config<||> ~> Service['murano-cfapi'] } diff --git a/manifests/client.pp b/manifests/client.pp index b6036f3..c522bcc 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -12,6 +12,7 @@ class murano::client( $package_ensure = 'present', ) { + include ::murano::deps include ::murano::params package { 'python-muranoclient': diff --git a/manifests/config.pp b/manifests/config.pp index 901d83c..d80258c 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -36,6 +36,8 @@ class murano::config ( $murano_cfapi_paste_config = {} ) { + include ::murano::deps + validate_hash($murano_config) validate_hash($murano_cfapi_config) validate_hash($murano_paste_config) diff --git a/manifests/dashboard.pp b/manifests/dashboard.pp index 1ce87d9..7235687 100644 --- a/manifests/dashboard.pp +++ b/manifests/dashboard.pp @@ -63,6 +63,7 @@ class murano::dashboard( $sync_db = true, ) { + include ::murano::deps include ::murano::params package { 'murano-dashboard': diff --git a/manifests/db.pp b/manifests/db.pp index d4c8c6f..10d717f 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -49,6 +49,8 @@ class murano::db ( $database_db_max_retries = $::os_service_default, ) { + include ::murano::deps + # NOTE(aderyugin): In order to keep backward compatibility we rely on the pick function # to use murano:: if murano::db:: isn't specified. $database_connection_real = pick($::murano::database_connection, $database_connection) diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 4f78c34..33a1c97 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -42,6 +42,8 @@ class murano::db::mysql( $collate = 'utf8_general_ci', ) { + include ::murano::deps + validate_string($password) ::openstacklib::db::mysql{ 'murano': @@ -54,5 +56,8 @@ class murano::db::mysql( allowed_hosts => $allowed_hosts, } - ::Openstacklib::Db::Mysql['murano'] ~> Exec<| title == 'murano-dbmanage' |> + Anchor['murano::db::begin'] + ~> Class['murano::db::mysql'] + ~> Anchor['murano::db::end'] + } diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index 52bb5ce..14ea78a 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -32,6 +32,8 @@ class murano::db::postgresql( $privileges = 'ALL', ) { + include ::murano::deps + validate_string($password) ::openstacklib::db::postgresql { 'murano': @@ -42,6 +44,8 @@ class murano::db::postgresql( privileges => $privileges, } - ::Openstacklib::Db::Postgresql['murano'] ~> Exec<| title == 'murano-dbmanage' |> + Anchor['murano::db::begin'] + ~> Class['murano::db::postgresql'] + ~> Anchor['murano::db::end'] } diff --git a/manifests/db/sync.pp b/manifests/db/sync.pp index f4c419f..51a414b 100644 --- a/manifests/db/sync.pp +++ b/manifests/db/sync.pp @@ -3,13 +3,9 @@ # class murano::db::sync { + include ::murano::deps include ::murano::params - Package <| title == 'murano-common' |> ~> Exec['murano-dbmanage'] - Exec['murano-dbmanage'] ~> Service <| tag == 'murano-service' |> - - Murano_config <| title == 'database/connection' |> ~> Exec['murano-dbmanage'] - exec { 'murano-dbmanage': command => $::murano::params::dbmanage_command, path => '/usr/bin', @@ -18,6 +14,12 @@ class murano::db::sync { try_sleep => 5, tries => 10, logoutput => on_failure, + subscribe => [ + Anchor['murano::install::end'], + Anchor['murano::config::end'], + Anchor['murano::dbsync::begin'] + ], + notify => Anchor['murano::dbsync::end'], } } diff --git a/manifests/deps.pp b/manifests/deps.pp new file mode 100644 index 0000000..dae0815 --- /dev/null +++ b/manifests/deps.pp @@ -0,0 +1,35 @@ +# == Class: murano::deps +# +# Murano anchors and dependency management +# +class murano::deps { + # Setup anchors for install, config and service phases of the module. These + # anchors allow external modules to hook the begin and end of any of these + # phases. Package or service management can also be replaced by ensuring the + # package is absent or turning off service management and having the + # replacement depend on the appropriate anchors. When applicable, end tags + # should be notified so that subscribers can determine if installation, + # config or service state changed and act on that if needed. + anchor { 'murano::install::begin': } + -> Package<| tag == 'murano-package'|> + ~> anchor { 'murano::install::end': } + -> anchor { 'murano::config::begin': } + -> Murano_config<||> + ~> anchor { 'murano::config::end': } + -> anchor { 'murano::db::begin': } + -> anchor { 'murano::db::end': } + ~> anchor { 'murano::dbsync::begin': } + -> anchor { 'murano::dbsync::end': } + ~> anchor { 'murano::service::begin': } + ~> Service<| tag == 'murano-service' |> + ~> anchor { 'murano::service::end': } + + # policy config should occur in the config block also. + Anchor['murano::config::begin'] + -> Openstacklib::Policy::Base<||> + ~> Anchor['murano::config::end'] + + # Installation or config changes will always restart services. + Anchor['murano::install::end'] ~> Anchor['murano::service::begin'] + Anchor['murano::config::end'] ~> Anchor['murano::service::begin'] +} diff --git a/manifests/engine.pp b/manifests/engine.pp index 46872a0..670d7cf 100644 --- a/manifests/engine.pp +++ b/manifests/engine.pp @@ -27,12 +27,10 @@ class murano::engine( $workers = $::os_service_default, ) { + include ::murano::deps include ::murano::params include ::murano::policy - Murano_config<||> ~> Service['murano-engine'] - Class['murano::policy'] -> Service['murano-engine'] - if $manage_service { if $enabled { $service_ensure = 'running' @@ -52,13 +50,10 @@ class murano::engine( } service { 'murano-engine': - ensure => $service_ensure, - name => $::murano::params::engine_service_name, - enable => $enabled, - require => Package['murano-engine'], - tag => 'murano-service', + ensure => $service_ensure, + name => $::murano::params::engine_service_name, + enable => $enabled, + tag => 'murano-service', } - Package['murano-engine'] ~> Service['murano-engine'] - } diff --git a/manifests/init.pp b/manifests/init.pp index 36d787f..e53f48b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -320,6 +320,7 @@ class murano( $rabbit_os_password = 'guest', ) { + include ::murano::deps include ::murano::params include ::murano::logging include ::murano::policy diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index 15b35f2..c11f261 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -85,6 +85,8 @@ class murano::keystone::auth( $internal_url = 'http://127.0.0.1:8082', ) { + include ::murano::deps + keystone::resource::service_identity { 'murano': configure_user => $configure_user, configure_user_role => $configure_user_role, diff --git a/manifests/keystone/cfapi_auth.pp b/manifests/keystone/cfapi_auth.pp index 5a22cea..8006390 100644 --- a/manifests/keystone/cfapi_auth.pp +++ b/manifests/keystone/cfapi_auth.pp @@ -85,6 +85,7 @@ class murano::keystone::cfapi_auth( $internal_url = 'http://127.0.0.1:8083', ) { + include ::murano::deps keystone::resource::service_identity { 'murano-cfapi': configure_user => $configure_user, diff --git a/manifests/logging.pp b/manifests/logging.pp index 8d2b891..ed5b3ec 100644 --- a/manifests/logging.pp +++ b/manifests/logging.pp @@ -104,6 +104,8 @@ class murano::logging( $log_date_format = $::os_service_default, ) { + include ::murano::deps + # NOTE(aderyugin): In order to keep backward compatibility we rely on the pick function # to use murano:: if murano::logging:: isn't specified. $use_syslog_real = pick($::murano::use_syslog, $use_syslog) diff --git a/manifests/policy.pp b/manifests/policy.pp index 1a59c6b..36ab9e0 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -17,6 +17,8 @@ class murano::policy ( $policy_path = '/etc/murano/policy.json', ) { + include ::murano::deps + validate_hash($policies) Openstacklib::Policy::Base { diff --git a/releasenotes/notes/external_install_mgmt_hook-ef172966391da942.yaml b/releasenotes/notes/external_install_mgmt_hook-ef172966391da942.yaml new file mode 100644 index 0000000..eeb3c9b --- /dev/null +++ b/releasenotes/notes/external_install_mgmt_hook-ef172966391da942.yaml @@ -0,0 +1,10 @@ +--- +prelude: > + Add hooks for external install & svc management. +features: + - This adds defined anchor points for external modules to + hook into the software install, config and service dependency + chain. This allows external modules to manage software + installation (virtualenv, containers, etc) and service management + (pacemaker) without needing rely on resources that may change or + be renamed. diff --git a/spec/classes/murano_cfapi_spec.rb b/spec/classes/murano_cfapi_spec.rb index 874e783..f5eeb04 100644 --- a/spec/classes/murano_cfapi_spec.rb +++ b/spec/classes/murano_cfapi_spec.rb @@ -12,6 +12,7 @@ describe 'murano::cfapi' do end shared_examples_for 'with default parameters' do + it { is_expected.to contain_class('murano::deps') } it { is_expected.to contain_class('murano::params') } it { is_expected.to contain_class('murano::policy') } diff --git a/spec/classes/murano_db_sync_spec.rb b/spec/classes/murano_db_sync_spec.rb index bb01219..93967b0 100644 --- a/spec/classes/murano_db_sync_spec.rb +++ b/spec/classes/murano_db_sync_spec.rb @@ -12,7 +12,11 @@ describe 'murano::db::sync' do :refreshonly => 'true', :try_sleep => 5, :tries => 10, - :logoutput => 'on_failure' + :logoutput => 'on_failure', + :subscribe => ['Anchor[murano::install::end]', + 'Anchor[murano::config::end]', + 'Anchor[murano::dbsync::begin]'], + :notify => 'Anchor[murano::dbsync::end]', ) end diff --git a/spec/classes/murano_init_spec.rb b/spec/classes/murano_init_spec.rb index b017bc4..b024e5f 100644 --- a/spec/classes/murano_init_spec.rb +++ b/spec/classes/murano_init_spec.rb @@ -14,6 +14,7 @@ describe 'murano' do end context 'with default parameters' do + it { is_expected.to contain_class('murano::deps') } it { is_expected.to contain_class('murano::params') } it { is_expected.to contain_class('murano::policy') } it { is_expected.to contain_class('murano::db') } diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index 0f1b7dc..ae416b1 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -15,7 +15,6 @@ shared_examples 'generic murano service' do |service| is_expected.to contain_package(service[:name]).with({ :name => service[:package_name], :ensure => 'present', - :notify => ["Service[#{service[:name]}]"], :tag => [ 'openstack', 'murano-package'], }) is_expected.to contain_service(service[:name]).with({ @@ -41,7 +40,6 @@ shared_examples 'generic murano service' do |service| is_expected.to contain_package(service[:name]).with({ :name => service[:package_name], :ensure => '2014.2-1', - :notify => ["Service[#{service[:name]}]"], :tag => [ 'openstack', 'murano-package'], }) is_expected.to contain_service(service[:name]).with({