diff --git a/manifests/api.pp b/manifests/api.pp index 4701dc5..814bfeb 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -164,10 +164,6 @@ class watcher::api ( validate_string($watcher_client_password) - Watcher_config<||> ~> Service['watcher-api'] - Class['watcher::policy'] ~> Service['watcher-api'] - - Package['watcher-api'] -> Service['watcher-api'] package { 'watcher-api': ensure => $package_ensure, name => $::watcher::params::api_package_name, @@ -239,7 +235,7 @@ class watcher::api ( } } $validation_options_hash = merge($defaults, $validation_options) - create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Service[watcher-api]'}) + create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Anchor[watcher::service::end]'}) } } diff --git a/manifests/applier.pp b/manifests/applier.pp index 54311f2..911cdcc 100644 --- a/manifests/applier.pp +++ b/manifests/applier.pp @@ -50,9 +50,6 @@ class watcher::applier ( include ::watcher::params include ::watcher::deps - Watcher_config<||> ~> Service['watcher-applier'] - - Package['watcher-applier'] -> Service['watcher-applier'] package { 'watcher-applier': ensure => $package_ensure, name => $::watcher::params::applier_package_name, diff --git a/manifests/config.pp b/manifests/config.pp index 54adaf2..65a07a6 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -24,6 +24,8 @@ class watcher::config ( $watcher_config = {}, ) { + include ::watcher::deps + validate_hash($watcher_config) create_resources('watcher_config', $watcher_config) diff --git a/manifests/db.pp b/manifests/db.pp index 3f0fc1a..35f4aa5 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -49,6 +49,8 @@ class watcher::db ( $database_max_overflow = $::os_service_default, ) { + include ::watcher::deps + validate_re($database_connection, '^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?') diff --git a/manifests/db/create_schema.pp b/manifests/db/create_schema.pp index 22f603c..a592191 100644 --- a/manifests/db/create_schema.pp +++ b/manifests/db/create_schema.pp @@ -11,14 +11,15 @@ class watcher::db::create_schema( $extra_params = '--config-file /etc/watcher/watcher.conf', ) { + + include ::watcher::deps + exec { 'watcher-db-manage-create_schema': command => "watcher-db-manage ${extra_params} create_schema", path => '/usr/bin', user => 'watcher', refreshonly => true, subscribe => [ - Package['watcher'], - Watcher_config['database/connection'], Anchor['watcher::install::end'], Anchor['watcher::config::end'], Anchor['watcher::db::create_schema::begin'] @@ -26,5 +27,4 @@ class watcher::db::create_schema( notify => Anchor['watcher::db::create_schema::end'], } - Exec['watcher-db-manage-create_schema'] ~> Service<| title == 'watcher-db-manage-create_schema' |> } diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 409c32f..6503fcc 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -53,6 +53,8 @@ class watcher::db::mysql( $allowed_hosts = undef ) { + include ::watcher::deps + validate_string($password) ::openstacklib::db::mysql { 'watcher': @@ -65,7 +67,8 @@ class watcher::db::mysql( allowed_hosts => $allowed_hosts, } - ::Openstacklib::Db::Mysql['watcher'] ~> Exec<| title == 'watcher-db-manage-create_schema' |> - ::Openstacklib::Db::Mysql['watcher'] ~> Exec<| title == 'watcher-db-manage-upgrade' |> + Anchor['watcher::db::begin'] + ~> Class['watcher::db::mysql'] + ~> Anchor['watcher::db::end'] } diff --git a/manifests/db/postgresql.pp b/manifests/db/postgresql.pp index 75a1fd0..44f81b4 100644 --- a/manifests/db/postgresql.pp +++ b/manifests/db/postgresql.pp @@ -40,7 +40,7 @@ class watcher::db::postgresql( $privileges = 'ALL', ) { - Class['watcher::db::postgresql'] -> Service<| title == 'watcher' |> + include ::watcher::deps ::openstacklib::db::postgresql { 'watcher': password_hash => postgresql_password($user, $password), @@ -50,7 +50,8 @@ class watcher::db::postgresql( privileges => $privileges, } - ::Openstacklib::Db::Postgresql['watcher'] ~> Exec<| title == 'watcher-db-manage-create_schema' |> - ::Openstacklib::Db::Postgresql['watcher'] ~> Exec<| title == 'watcher-db-manage-upgrade' |> + Anchor['watcher::db::begin'] + ~> Class['watcher::db::postgresql'] + ~> Anchor['watcher::db::end'] } diff --git a/manifests/db/upgrade.pp b/manifests/db/upgrade.pp index 1a04a02..89bc7df 100644 --- a/manifests/db/upgrade.pp +++ b/manifests/db/upgrade.pp @@ -12,14 +12,15 @@ class watcher::db::upgrade( $extra_params = '--config-file /etc/watcher/watcher.conf', ) { + + include ::watcher::deps + exec { 'watcher-db-manage-upgrade': command => "watcher-db-manage ${extra_params} upgrade", path => '/usr/bin', user => 'watcher', refreshonly => true, subscribe => [ - Package['watcher'], - Watcher_config['database/connection'], Anchor['watcher::install::end'], Anchor['watcher::config::end'], Anchor['watcher::db::create_schema::end'], @@ -28,5 +29,4 @@ class watcher::db::upgrade( notify => Anchor['watcher::db::upgrade::end'], } - Exec['watcher-db-manage-upgrade'] ~> Service<| title == 'watcher-db-manage-upgrade' |> } diff --git a/manifests/decision_engine.pp b/manifests/decision_engine.pp index 6dc92ed..7c6b944 100644 --- a/manifests/decision_engine.pp +++ b/manifests/decision_engine.pp @@ -82,9 +82,6 @@ class watcher::decision_engine ( $decision_engine_notification_topics_real = $decision_engine_notification_topics } - Watcher_config<||> ~> Service['watcher-decision-engine'] - - Package['watcher-decision-engine'] -> Service['watcher-decision-engine'] package { 'watcher-decision-engine': ensure => $package_ensure, name => $::watcher::params::decision_engine_package_name, diff --git a/manifests/deps.pp b/manifests/deps.pp index b77f96f..07ea460 100644 --- a/manifests/deps.pp +++ b/manifests/deps.pp @@ -19,6 +19,11 @@ class watcher::deps { ~> Service<| tag == 'watcher-service' |> ~> anchor { 'watcher::service::end': } + # policy config should occur in the config block also. + Anchor['watcher::config::begin'] + -> Openstacklib::Policy::Base<||> + ~> Anchor['watcher::config::end'] + Anchor['watcher::install::end'] ~> Anchor['watcher::service::begin'] Anchor['watcher::config::end'] ~> Anchor['watcher::service::begin'] diff --git a/manifests/init.pp b/manifests/init.pp index 29e004a..61025fc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -382,7 +382,6 @@ class watcher ( include ::watcher::db include ::watcher::logging - Package['watcher'] -> Class['watcher::policy'] package { 'watcher': ensure => $ensure_package, name => $::watcher::params::common_package_name, diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index c1c23f1..94a6667 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -69,12 +69,17 @@ class watcher::keystone::auth ( $internal_url = 'http://127.0.0.1:9322', ) { + include ::watcher::deps + $real_service_name = pick($service_name, $auth_name) if $configure_user_role { - Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'watcher-server' |> + Keystone_user_role["${auth_name}@${tenant}"] ~> Anchor['watcher::service::end'] + } + + if $configure_endpoint { + Keystone_endpoint["${region}/${real_service_name}::${service_type}"] ~> Anchor['watcher::service::end'] } - Keystone_endpoint["${region}/${real_service_name}::${service_type}"] ~> Service <| name == 'watcher-server' |> keystone::resource::service_identity { 'watcher': configure_user => $configure_user, diff --git a/manifests/logging.pp b/manifests/logging.pp index a7d69d5..6a9f411 100644 --- a/manifests/logging.pp +++ b/manifests/logging.pp @@ -113,6 +113,8 @@ class watcher::logging( $log_date_format = $::os_service_default, ) { + include ::watcher::deps + oslo::log { 'watcher_config': use_stderr => $use_stderr, use_syslog => $use_syslog, diff --git a/manifests/policy.pp b/manifests/policy.pp index a52158e..466fc34 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -28,6 +28,8 @@ class watcher::policy ( $policy_path = '/etc/watcher/policy.json', ) { + include ::watcher::deps + validate_hash($policies) Openstacklib::Policy::Base { diff --git a/spec/classes/watcher_api_spec.rb b/spec/classes/watcher_api_spec.rb index cd441fd..40ddcef 100644 --- a/spec/classes/watcher_api_spec.rb +++ b/spec/classes/watcher_api_spec.rb @@ -18,6 +18,7 @@ describe 'watcher::api' do end it { is_expected.to contain_class('watcher::params') } + it { is_expected.to contain_class('watcher::deps') } it 'installs watcher-api package' do is_expected.to contain_package('watcher-api').with( diff --git a/spec/classes/watcher_db_create_schema_spec.rb b/spec/classes/watcher_db_create_schema_spec.rb index 2f85da1..c946e5c 100644 --- a/spec/classes/watcher_db_create_schema_spec.rb +++ b/spec/classes/watcher_db_create_schema_spec.rb @@ -10,6 +10,12 @@ describe 'watcher::db::create_schema' do :path => '/usr/bin', :user => 'watcher', :refreshonly => 'true', + :subscribe => [ + 'Anchor[watcher::install::end]', + 'Anchor[watcher::config::end]', + 'Anchor[watcher::db::create_schema::begin]' + ], + :notify => 'Anchor[watcher::db::create_schema::end]', ) end @@ -26,6 +32,12 @@ describe 'watcher::db::create_schema' do :path => '/usr/bin', :user => 'watcher', :refreshonly => 'true', + :subscribe => [ + 'Anchor[watcher::install::end]', + 'Anchor[watcher::config::end]', + 'Anchor[watcher::db::create_schema::begin]' + ], + :notify => 'Anchor[watcher::db::create_schema::end]', ) } end diff --git a/spec/classes/watcher_db_upgrade_spec.rb b/spec/classes/watcher_db_upgrade_spec.rb index 539a114..dc8504c 100644 --- a/spec/classes/watcher_db_upgrade_spec.rb +++ b/spec/classes/watcher_db_upgrade_spec.rb @@ -10,6 +10,13 @@ describe 'watcher::db::upgrade' do :path => '/usr/bin', :user => 'watcher', :refreshonly => 'true', + :subscribe => [ + 'Anchor[watcher::install::end]', + 'Anchor[watcher::config::end]', + 'Anchor[watcher::db::create_schema::end]', + 'Anchor[watcher::db::upgrade::begin]' + ], + :notify => 'Anchor[watcher::db::upgrade::end]', ) end @@ -26,6 +33,13 @@ describe 'watcher::db::upgrade' do :path => '/usr/bin', :user => 'watcher', :refreshonly => 'true', + :subscribe => [ + 'Anchor[watcher::install::end]', + 'Anchor[watcher::config::end]', + 'Anchor[watcher::db::create_schema::end]', + 'Anchor[watcher::db::upgrade::begin]' + ], + :notify => 'Anchor[watcher::db::upgrade::end]', ) } end diff --git a/spec/classes/watcher_init_spec.rb b/spec/classes/watcher_init_spec.rb index 31025e6..94b3fcd 100644 --- a/spec/classes/watcher_init_spec.rb +++ b/spec/classes/watcher_init_spec.rb @@ -26,6 +26,7 @@ describe 'watcher' do end it { is_expected.to contain_class('watcher::policy') } + it { is_expected.to contain_class('watcher::deps') } it 'configures rabbit' do is_expected.to contain_watcher_config('DEFAULT/rpc_backend').with_value('rabbit')