From f2cf31bf47f0536272f18c5844bb4c46ffb12eeb Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 18 Mar 2021 20:51:44 +0200 Subject: [PATCH] [goal] Deprecate the JSON formatted policy file As per the community goal of migrating the policy file the format from JSON to YAML[1], we need to replace policy.json to policy.yaml and remove deprecated policy.json. config_template has been choosen instead of the copy, since it can properly handle content that has been lookuped. We make a separate task not to restart service when it's not needed. [1] https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/777384 Change-Id: I9c358f7d8bd655712748717b391cbf6a58b196c7 --- handlers/main.yml | 27 ++------------------------- tasks/mistral_post_install.yml | 28 ++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index b9cb043..aff6376 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -28,34 +28,11 @@ - "Restart mistral services" - "venv changed" -# Note (odyssey4me): -# The policy.json file is currently read continually by the services -# and is not only read on service start. We therefore cannot template -# directly to the file read by the service because the new policies -# may not be valid until the service restarts. This is particularly -# important during a major upgrade. We therefore only put the policy -# file in place after the service has been stopped. -# -- name: Copy new policy file into place - copy: - src: "/etc/mistral/policy.json-{{ mistral_venv_tag }}" - dest: "/etc/mistral/policy.json" - owner: "root" - group: "{{ mistral_system_group_name }}" - mode: "0640" - remote_src: yes - when: - - mistral_policy_overrides != {} - listen: - - "Restart mistral services" - - "venv changed" - -- name: Remove legacy policy.json file +# NOTE (noonedeadpunk): Remove this task after Xena release +- name: Remove obsoleted policy.json file: path: "/etc/mistral/policy.json" state: absent - when: - - mistral_policy_overrides == {} listen: - "Restart mistral services" - "venv changed" diff --git a/tasks/mistral_post_install.yml b/tasks/mistral_post_install.yml index cd4c00c..1873ad4 100644 --- a/tasks/mistral_post_install.yml +++ b/tasks/mistral_post_install.yml @@ -32,12 +32,24 @@ - Restart mistral services - Restart uwsgi services -- name: Implement policy.json if there are overrides configured - copy: - content: "{{ mistral_policy_overrides | to_nice_json }}" - dest: "/etc/mistral/policy.json-{{ mistral_venv_tag }}" +- name: Implement policy.yaml if there are overrides configured + config_template: + content: "{{ mistral_policy_overrides }}" + dest: "/etc/mistral/policy.yaml" + owner: "root" + group: "{{ mistral_system_group_name }}" + mode: "0640" + config_type: yaml when: - - mistral_policy_overrides != {} - notify: - - Manage LB - - Restart mistral services \ No newline at end of file + - mistral_policy_overrides | length > 0 + tags: + - mistral-policy-override + +- name: Remove legacy policy.yaml file + file: + path: "/etc/mistral/policy.yaml" + state: absent + when: + - mistral_policy_overrides | length == 0 + tags: + - mistral-policy-override