From f1f47cad9e746ee3d9baaec5128dcf333ccea69b Mon Sep 17 00:00:00 2001 From: somayeh_hajiahmadi Date: Tue, 12 Sep 2023 18:25:33 +0330 Subject: [PATCH] use policy.yaml instead of policy.json due to latest change on gnocchi Change-Id: If05936d25db3329b4204172f3b800ddf3417b9b7 --- handlers/main.yml | 18 ++++++++----- tasks/gnocchi_post_install.yml | 47 ++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 19c1e24..929ba4b 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -30,8 +30,6 @@ listen: - "Restart gnocchi services" - "venv changed" - - "systemd service changed" - - "cert installed" # Note (odyssey4me): # The policy.json file is currently read continually by the services @@ -43,8 +41,8 @@ # - name: Copy new policy file into place copy: - src: "/etc/gnocchi/policy.json-{{ gnocchi_venv_tag }}" - dest: "/etc/gnocchi/policy.json" + src: "/etc/gnocchi/policy.yaml-{{ gnocchi_venv_tag }}" + dest: "/etc/gnocchi/policy.yaml" owner: "root" group: "{{ gnocchi_system_group_name }}" mode: "0640" @@ -70,5 +68,13 @@ listen: - "Restart gnocchi services" - "venv changed" - - "systemd service changed" - - "cert installed" + +# NOTE(noonedeadpunk): This task is created due to migration from apache to uwsgi +# which was introduced during train release. It can be dropped afterwards. +- name: Restart web server + service: + name: "{{ gnocchi_system_service_name }}" + enabled: yes + state: "restarted" + daemon_reload: yes + failed_when: false diff --git a/tasks/gnocchi_post_install.yml b/tasks/gnocchi_post_install.yml index 99e582e..66ab0f2 100644 --- a/tasks/gnocchi_post_install.yml +++ b/tasks/gnocchi_post_install.yml @@ -25,7 +25,7 @@ - name: Copy gnocchi configuration files openstack.config_template.config_template: content: "{{ item.content | default(omit) }}" - src: "{{ item.src | default(omit) }}" + src: "{{ item.src | default(omit) }}" dest: "{{ item.dest }}" owner: "{{ item.owner | default(gnocchi_system_user_name) }}" group: "{{ item.group | default(gnocchi_system_group_name) }}" @@ -41,10 +41,47 @@ config_overrides: "{{ gnocchi_api_paste_ini_overrides }}" config_type: "ini" content: "{{ gnocchi_api_paste_user_content | default(gnocchi_api_paste_default_content, true) }}" - - dest: "/etc/gnocchi/policy.json-{{ gnocchi_venv_tag }}" - config_overrides: "{{ gnocchi_policy_overrides }}" - config_type: "json" - content: "{{ gnocchi_policy_user_content | default(gnocchi_policy_default_content, true) }}" notify: - Restart gnocchi services - Restart uwsgi services + - Restart web server + +- name: Implement policy.yaml if there are overrides configured + openstack.config_template.config_template: + content: "{{ gnocchi_policy_overrides }}" + dest: "/etc/gnocchi/policy.yaml-{{ gnocchi_venv_tag }}" + owner: "root" + group: "{{ gnocchi_system_group_name }}" + mode: "0640" + config_type: yaml + when: + - gnocchi_policy_overrides | length > 0 + tags: + - gnocchi-policy-override + +- name: Remove legacy policy.yaml file + file: + path: "/etc/gnocchi/policy.yaml" + state: absent + when: + - gnocchi_policy_overrides | length == 0 + tags: + - gnocchi-policy-override + +# NOTE(noonedeadpunk): This task is created due to migration from apache to uwsgi +# which was introduced during train release. It can be dropped afterwards. +- name: Drop Apache related configs + file: + path: "{{ item }}" + state: absent + with_items: "{{ gnocchi_apache_config }}" + notify: + - Restart web server + +- name: Stop Apache listening on Gnocchi port + lineinfile: + path: "{{ gnocchi_apache_ports }}" + state: absent + line: "Listen {{ gnocchi_service_port }}" + notify: + - Restart web server