From 109698e942a3c20a3e4d0fc66ffa94e741d2738e Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 18 Mar 2021 19:10:26 +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: I701473f4d99e0be06dea494eee4f08212bb7d853 --- handlers/main.yml | 9 +++++++++ tasks/ironic_post_install.yml | 25 ++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 4d9b7a57..e117ab62 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -23,6 +23,15 @@ listen: - "venv changed" +# NOTE (noonedeadpunk): Remove this task after Xena release +- name: Remove obsoleted policy.json + file: + path: "/etc/ironic/policy.json" + state: absent + listen: + - "Restart ironic services" + - "venv changed" + - name: Restart tftpd service: name: "{{ ironic_tftpd_service_name }}" diff --git a/tasks/ironic_post_install.yml b/tasks/ironic_post_install.yml index ea283bbf..b0262437 100644 --- a/tasks/ironic_post_install.yml +++ b/tasks/ironic_post_install.yml @@ -120,12 +120,27 @@ - Restart ironic services - Restart uwsgi services -- name: Implement policy.json - copy: - content: "{{ ironic_policy_overrides | to_nice_json }}" - dest: "/etc/ironic/policy.json" +- name: Implement policy.yaml + config_template: + content: "{{ ironic_policy_overrides }}" + dest: "/etc/ironic/policy.yaml" + owner: "{{ ironic_system_user_name }}" + group: "{{ ironic_system_group_name }}" + mode: "0644" + config_type: yaml when: - - ironic_policy_overrides != {} + - ironic_policy_overrides | length > 0 + tags: + - ironic-policy-override + +- name: Remove legacy policy.yaml file + file: + path: "/etc/ironic/policy.yaml" + state: absent + when: + - ironic_policy_overrides | length == 0 + tags: + - ironic-policy-override - name: Copy rootwrap filters copy: