From 8fe204a3f099232431be81cf27f537279e7d04f8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 8 Apr 2024 11:17:09 +0900 Subject: [PATCH] Refactor resource dependencies This refactors resource dependencies to avoid unnecessary dependencies across services. Change-Id: I0f0c12f77eb39cb1d1c68fe2b02050ada257aabb --- puppet-{{cookiecutter.project_name}}/manifests/db.pp | 4 ++++ puppet-{{cookiecutter.project_name}}/manifests/deps.pp | 9 --------- .../manifests/keystone/authtoken.pp | 2 ++ puppet-{{cookiecutter.project_name}}/manifests/policy.pp | 6 +++++- .../classes/{{cookiecutter.project_name}}_policy_spec.rb | 2 -- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/puppet-{{cookiecutter.project_name}}/manifests/db.pp b/puppet-{{cookiecutter.project_name}}/manifests/db.pp index 24fc047..41d33e3 100644 --- a/puppet-{{cookiecutter.project_name}}/manifests/db.pp +++ b/puppet-{{cookiecutter.project_name}}/manifests/db.pp @@ -61,4 +61,8 @@ class {{cookiecutter.project_name}}::db ( max_overflow => $database_max_overflow, pool_timeout => $database_pool_timeout, } + + # all db settings should be applied and all packages should be installed + # before dbsync starts + Oslo::Db['{{cookiecutter.project_name}}_config'] -> Anchor['{{cookiecutter.project_name}}::dbsync::begin'] } diff --git a/puppet-{{cookiecutter.project_name}}/manifests/deps.pp b/puppet-{{cookiecutter.project_name}}/manifests/deps.pp index 0f2ecbd..e1a62a2 100644 --- a/puppet-{{cookiecutter.project_name}}/manifests/deps.pp +++ b/puppet-{{cookiecutter.project_name}}/manifests/deps.pp @@ -27,15 +27,6 @@ class {{cookiecutter.project_name}}::deps { ~> Service<| tag == '{{cookiecutter.project_name}}-service' |> ~> anchor { '{{cookiecutter.project_name}}::service::end': } - # all db settings should be applied and all packages should be installed - # before dbsync starts - Oslo::Db<||> -> Anchor['{{cookiecutter.project_name}}::dbsync::begin'] - - # policy config should occur in the config block also. - Anchor['{{cookiecutter.project_name}}::config::begin'] - -> Openstacklib::Policy<| tag == '{{cookiecutter.project_name}}' |> - ~> Anchor['{{cookiecutter.project_name}}::config::end'] - # Installation or config changes will always restart services. Anchor['{{cookiecutter.project_name}}::install::end'] ~> Anchor['{{cookiecutter.project_name}}::service::begin'] Anchor['{{cookiecutter.project_name}}::config::end'] ~> Anchor['{{cookiecutter.project_name}}::service::begin'] diff --git a/puppet-{{cookiecutter.project_name}}/manifests/keystone/authtoken.pp b/puppet-{{cookiecutter.project_name}}/manifests/keystone/authtoken.pp index d7bdf5a..d0ca226 100644 --- a/puppet-{{cookiecutter.project_name}}/manifests/keystone/authtoken.pp +++ b/puppet-{{cookiecutter.project_name}}/manifests/keystone/authtoken.pp @@ -272,5 +272,7 @@ class {{cookiecutter.project_name}}::keystone::authtoken( service_type => $service_type, interface => $interface, } + + Keystone::Resource::Authtoken['{{cookiecutter.project_name}}_config'] -> Anchor['{{cookiecutter.project_name}}::service::begin'] } diff --git a/puppet-{{cookiecutter.project_name}}/manifests/policy.pp b/puppet-{{cookiecutter.project_name}}/manifests/policy.pp index 470ed2c..b24525c 100644 --- a/puppet-{{cookiecutter.project_name}}/manifests/policy.pp +++ b/puppet-{{cookiecutter.project_name}}/manifests/policy.pp @@ -65,11 +65,15 @@ class {{cookiecutter.project_name}}::policy ( file_group => $::{{cookiecutter.project_name}}::params::group, file_format => 'yaml', purge_config => $purge_config, - tag => '{{cookiecutter.project_name}}', } create_resources('openstacklib::policy', { $policy_path => $policy_parameters }) + # policy config should occur in the config block also. + Anchor['{{cookiecutter.project_name}}::config::begin'] + -> Openstacklib::Policy[$policy_path] + -> Anchor['{{cookiecutter.project_name}}::config::end'] + oslo::policy { '{{cookiecutter.project_name}}_config': enforce_scope => $enforce_scope, enforce_new_defaults => $enforce_new_defaults, diff --git a/puppet-{{cookiecutter.project_name}}/spec/classes/{{cookiecutter.project_name}}_policy_spec.rb b/puppet-{{cookiecutter.project_name}}/spec/classes/{{cookiecutter.project_name}}_policy_spec.rb index d960121..5ac75de 100644 --- a/puppet-{{cookiecutter.project_name}}/spec/classes/{{cookiecutter.project_name}}_policy_spec.rb +++ b/puppet-{{cookiecutter.project_name}}/spec/classes/{{cookiecutter.project_name}}_policy_spec.rb @@ -33,7 +33,6 @@ describe '{{cookiecutter.project_name}}::policy' do :file_group => '{{cookiecutter.project_name}}', :file_format => 'yaml', :purge_config => false, - :tag => '{{cookiecutter.project_name}}', ) is_expected.to contain_oslo__policy('{{cookiecutter.project_name}}_config').with( :enforce_scope => false, @@ -64,7 +63,6 @@ describe '{{cookiecutter.project_name}}::policy' do :file_group => '{{cookiecutter.project_name}}', :file_format => 'yaml', :purge_config => true, - :tag => '{{cookiecutter.project_name}}', ) is_expected.to contain_oslo__policy('{{cookiecutter.project_name}}_config').with( :enforce_scope => false,