diff --git a/tasks/keystone_nginx.yml b/tasks/keystone_nginx.yml index 1df89e65..5cdf0c77 100644 --- a/tasks/keystone_nginx.yml +++ b/tasks/keystone_nginx.yml @@ -27,21 +27,38 @@ - Manage LB - Restart web server -- name: Configure custom nginx log format +- name: Ensure configuration directories exist + file: + path: "{{ item }}" + state: directory + with_items: + - "/etc/nginx/{{ keystone_nginx_conf_path }}" + - "/etc/nginx/conf.d" + +# TODO(odyssey4me): +# This is to cater for P->Q, Q-R upgrades and can be removed in S +- name: Remove previously implemented custom nginx log format lineinfile: - # NOTE(hwoarang) Not every nginx.conf file is the same - # so it's best if we just append new stuff after known starting blocks. - insertafter: http { dest: "/etc/nginx/nginx.conf" line: "log_format custom '{{ keystone_nginx_access_log_format_combined }} {{ keystone_nginx_access_log_format_extras }}';" + state: absent notify: - Manage LB - Restart web server -- name: Ensure configuration directory exists - file: - path: "/etc/nginx/{{ keystone_nginx_conf_path }}" - state: directory +- name: Configure custom nginx log format + copy: + # NOTE(odyssey4me): + # To cater for the situation where there are no containers, or + # nginx is shared in some way, it's better to add custom directives + # for nginx.conf into a conf.d file. That way it's never overwritten. + content: | + # Ansible managed + log_format custom '{{ keystone_nginx_access_log_format_combined }} {{ keystone_nginx_access_log_format_extras }}'; + dest: "/etc/nginx/conf.d/custom_log.conf" + notify: + - Manage LB + - Restart web server # Configure app - name: Configure virtual hosts