From 6b5a93edb91d0f98ca5e1a20d20806a9e53eb61f Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 16 Mar 2021 16:49:23 +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. [1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html Change-Id: Iede5a9f0387baaf9c72bd060b59435ffaa76f1bd --- handlers/main.yml | 9 +++++++++ tasks/cinder_post_install.yml | 27 ++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 2118c5f1..6c6411eb 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -28,6 +28,15 @@ - "Restart cinder services" - "venv changed" +# NOTE (noonedeadpunk): Remove this task after Xena release +- name: Remove obsoleted policy.json file + file: + path: "/etc/cinder/policy.json" + state: absent + listen: + - Restart cinder services + - venv changed + - name: Start services service: name: "{{ item.service_name }}" diff --git a/tasks/cinder_post_install.yml b/tasks/cinder_post_install.yml index 9e9f5055..79893f62 100644 --- a/tasks/cinder_post_install.yml +++ b/tasks/cinder_post_install.yml @@ -63,20 +63,29 @@ - cinder-config - cinder-post-install -- name: Implement policy.json if there are overrides configured - copy: - content: "{{ cinder_policy_overrides | to_nice_json }}" - dest: "/etc/cinder/policy.json" - notify: - - Manage LB - - Restart cinder services - - Restart uwsgi services +- name: Implement policy.yaml if there are overrides configured + config_template: + content: "{{ cinder_policy_overrides }}" + dest: "/etc/cinder/policy.yaml" + owner: "root" + group: "{{ cinder_system_group_name }}" + mode: "0640" + config_type: yaml when: - - cinder_policy_overrides != {} + - cinder_policy_overrides | length > 0 tags: - cinder-config - cinder-policy-override +- name: Remove legacy policy.yaml file + file: + path: "/etc/cinder/policy.yaml" + state: absent + when: + - cinder_policy_overrides | length == 0 + tags: + - cinder-policy-override + # NOTE(cloudnull): This is using "cp" instead of copy with a remote_source # because we only want to copy the original files once. and we # don't want to need multiple tasks.