From da09cb83bbb4491b268f753d18dafdff30f94775 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 22 Mar 2021 18:01:35 +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 Change-Id: I3ff3ce4f150854ece690f1bcbd7183f511fccf2e --- handlers/main.yml | 9 +++++++++ tasks/nova_post_install.yml | 28 +++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 3c7d5b01..60704077 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -60,6 +60,15 @@ - "Restart nova services" - "venv changed" +# NOTE (noonedeadpunk): Remove this task after Xena release +- name: Remove obsoleted policy.json + file: + path: "/etc/nova/policy.json" + state: absent + listen: + - "Restart nova services" + - "venv changed" + - name: Start services service: name: "{{ item.service_name }}" diff --git a/tasks/nova_post_install.yml b/tasks/nova_post_install.yml index eed3c8d2..710518ec 100644 --- a/tasks/nova_post_install.yml +++ b/tasks/nova_post_install.yml @@ -81,16 +81,26 @@ - nova-config - nova-post-install -- name: Implement policy.json if there are overrides configured - copy: - content: "{{ nova_policy_overrides | to_nice_json }}" - dest: "/etc/nova/policy.json" +- name: Implement policy.yaml if there are overrides configured + config_template: + content: "{{ nova_policy_overrides }}" + dest: "/etc/nova/policy.yaml" + owner: "root" + group: "{{ nova_system_group_name }}" + mode: "0640" + config_type: yaml when: - - nova_policy_overrides != {} - notify: - - Manage LB - - Restart nova services - - Restart uwsgi services + - nova_policy_overrides | length > 0 + tags: + - nova-config + - nova-policy-override + +- name: Remove legacy policy.yaml file + file: + path: "/etc/nova/policy.yaml" + state: absent + when: + - nova_policy_overrides | length == 0 tags: - nova-config - nova-policy-override