Use uri module for git sourced configs
The current mechanism uses a lookup, causing the
fetch of the default templates to happen via curl
from the deployment node. This causes problems if
the deployment node does not have access to the
repo server web service, which may be the case in
high security environments.
This patch changes the mechanism to only use the
lookup module for the file content that is on the
deployment node, then falls back to using the uri
module to fetch the default content. This ensures
that the deployment node does not have to reach
into the environment for the content.
Change-Id: Ia067a7cd2bc4460462b55f4631eba6e8eb693b0f
(cherry picked from commit ff82da926b
)
This commit is contained in:
parent
bf1ded9755
commit
5932746fe1
|
@ -38,7 +38,6 @@ gnocchi_git_install_branch: stable/3.1
|
|||
gnocchi_developer_mode: false
|
||||
gnocchi_developer_constraints:
|
||||
- "git+{{ gnocchi_git_repo }}@{{ gnocchi_git_install_branch }}#egg=gnocchi"
|
||||
gnocchi_git_config_lookup_location: https://git.openstack.org/cgit/openstack/gnocchi/plain/
|
||||
|
||||
#: Use of deprecated config options will cause a fatal application error
|
||||
gnocchi_fatal_deprecations: false
|
||||
|
@ -185,8 +184,15 @@ gnocchi_role_project_group: gnocchi_all
|
|||
gnocchi_api_paste_default_file_path: "/etc/openstack_deploy/gnocchi/api-paste.ini"
|
||||
gnocchi_policy_default_file_path: "/etc/openstack_deploy/gnocchi/policy.json"
|
||||
|
||||
# If the above-mentioned files do not exist, then these
|
||||
# paths will be used to find the files from the git config
|
||||
# lookup location.
|
||||
gnocchi_git_config_lookup_location: https://git.openstack.org/cgit/openstack/gnocchi/plain
|
||||
gnocchi_api_paste_git_file_path: "gnocchi/rest//api-paste.ini?h={{ gnocchi_git_install_branch }}"
|
||||
gnocchi_policy_git_file_path: "gnocchi/rest/policy.json?h={{ gnocchi_git_install_branch }}"
|
||||
|
||||
#: Tunable var-based overrides
|
||||
# The contents of these are templated over the default files.
|
||||
gnocchi_conf_overrides: {}
|
||||
gnocchi_api_paste_ini_overrides: {}
|
||||
gnocchi_conf_overrides: {}
|
||||
gnocchi_policy_overrides: {}
|
||||
|
|
|
@ -13,40 +13,38 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Drop Gnocchi Config
|
||||
config_template:
|
||||
src: "gnocchi.conf.j2"
|
||||
dest: "/etc/gnocchi/gnocchi.conf"
|
||||
owner: "{{ gnocchi_system_user_name }}"
|
||||
group: "{{ gnocchi_system_group_name }}"
|
||||
mode: "0644"
|
||||
config_overrides: "{{ gnocchi_conf_overrides }}"
|
||||
config_type: "ini"
|
||||
notify:
|
||||
- Restart gnocchi services
|
||||
- Restart web server
|
||||
- name: Retrieve default configuration files
|
||||
uri:
|
||||
url: "{{ item }}"
|
||||
return_content: yes
|
||||
with_items:
|
||||
- "{{ gnocchi_git_config_lookup_location }}/{{ gnocchi_api_paste_git_file_path }}"
|
||||
- "{{ gnocchi_git_config_lookup_location }}/{{ gnocchi_policy_git_file_path }}"
|
||||
register: _git_file_fetch
|
||||
|
||||
- name: Retrieve and config_template upstream files
|
||||
- name: Copy gnocchi configuration files
|
||||
config_template:
|
||||
content: "{{ lookup('pipe', item.content) | string }}"
|
||||
content: "{{ item.content | 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) }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
config_overrides: "{{ item.config_overrides }}"
|
||||
config_type: "{{ item.config_type }}"
|
||||
with_items:
|
||||
- name: "api-paste.ini"
|
||||
dest: "/etc/gnocchi/api-paste.ini"
|
||||
- src: "gnocchi.conf.j2"
|
||||
dest: "/etc/gnocchi/gnocchi.conf"
|
||||
config_overrides: "{{ gnocchi_conf_overrides }}"
|
||||
config_type: "ini"
|
||||
- dest: "/etc/gnocchi/api-paste.ini"
|
||||
config_overrides: "{{ gnocchi_api_paste_ini_overrides }}"
|
||||
config_type: "ini"
|
||||
content: |
|
||||
cat {{ gnocchi_api_paste_default_file_path }} 2>/dev/null || \
|
||||
curl -s {{ gnocchi_git_config_lookup_location }}gnocchi/rest/api-paste.ini?h={{ gnocchi_git_install_branch }}
|
||||
- name: "policy.json"
|
||||
dest: "/etc/gnocchi/policy.json-{{ gnocchi_venv_tag }}"
|
||||
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: |
|
||||
cat {{ gnocchi_policy_default_file_path }} 2>/dev/null || \
|
||||
curl -s {{ gnocchi_git_config_lookup_location }}gnocchi/rest/policy.json?h={{ gnocchi_git_install_branch }}
|
||||
content: "{{ gnocchi_policy_user_content | default(gnocchi_policy_default_content, true) }}"
|
||||
notify:
|
||||
- Restart gnocchi services
|
||||
- Restart web server
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
# Copyright 2017, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# These vars find a file on the deployment node, if it exists - otherwise the result is empty.
|
||||
gnocchi_api_paste_user_content: "{{ lookup('pipe', 'cat ' ~ gnocchi_api_paste_default_file_path ~ ' 2>/dev/null || true') }}"
|
||||
gnocchi_policy_user_content: "{{ lookup('pipe', 'cat ' ~ gnocchi_policy_default_file_path ~ ' 2>/dev/null || true') }}"
|
||||
|
||||
# These vars find the appropriate result content from the with_items loop
|
||||
gnocchi_api_paste_default_content: |
|
||||
{{ _git_file_fetch.results | selectattr('item', 'equalto', gnocchi_git_config_lookup_location ~ '/' ~ gnocchi_api_paste_git_file_path) | map(attribute='content') | first }}
|
||||
gnocchi_policy_default_content: |
|
||||
{{ _git_file_fetch.results | selectattr('item', 'equalto', gnocchi_git_config_lookup_location ~ '/' ~ gnocchi_policy_git_file_path) | map(attribute='content') | first }}
|
||||
|
Loading…
Reference in New Issue