Skip to content

nginx access.log configuration not taking #149

@andy-v-h

Description

@andy-v-h

Cookbook version

5.0.1

Chef-client version

12.17.44

Platform Details

CentOS release 6.9 (Final)

Last login: Thu Nov  2 22:11:29 2017 from 10.0.2.2
***
Chef-Client: vagrant.vagrantup.com
Hostname: vagrant.vagrantup.com
Environment: _default
Chef Server: chefzero://localhost:8889
---
Roles: No Roles Defined
Tags: No Tags Defined
Run_List: recipe[myorg_ohai], recipe[myorg_vagrant_base_box]
---
[vagrant@default-centos-6-chef-12-kitchen ~]$ cat /etc/centos-release 
CentOS release 6.9 (Final)
[vagrant@default-centos-6-chef-12-kitchen ~]$

Scenario:

I want to configure the embedded nginx server to publish access.log in a way that makes sense to splunk

Steps to Reproduce:

Added the nginx configuration to the attributes/defaults.rb

diff --git a/attributes/default.rb b/attributes/default.rb
index ca3598a..717f899 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -14,6 +14,11 @@ default['chef-server']['configuration'] = <<-EOS
 default_orgname "myorg"
 addons['install'] = false
 opscode_expander['nodes'] = 4
+nginx['access_log_options'] = 'splunk';
+nginx['log_formats'] = {
+  'splunk' => 'site="$server_name" server="$host” dest_port="$server_port" dest_ip="$server_addr" src="$remote_addr" src_ip="0.0.00"   user="$remote_user" time_local="$time_local" protocol="$server_protocol" status="$status" bytes_out="$bytes_sent" bytes_in="0" http_referer="$http_referer" http_user_agent="$http_user_agent" nginx_version="$nginx_version" http_x_forwarded_for="$http_x_forwarded_for" http_x_header="$http_x_header" uri_query="$query_string" uri_path="$uri" http_method="$request_method" response_time="$upstream_response_time" cookie="$http_cookie" request_time="$request_time" ', 
+  'main' => '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"'
+}
 nginx['ssl_certificate_key'] = '/var/opt/opscode/nginx/ca/wildcard.myorg.net.key'
 nginx['ssl_certificate'] = '/var/opt/opscode/nginx/ca/wildcard.myorg.net.pem'
 opscode_erchef['db_pool_size'] = 40

Expected Result:

the access.log would use the new splunk logging type.

Actual Result:

I can see that the configs make it to the runlist json but don't get written out to the /var/opt/opscode/nginx/etc directory for the embedded nginx server to use

[root@default-centos-6-chef-12-kitchen chef]# grep -r 'splunk'  /var/opt/opscode/nginx/etc/nginx.conf
[root@default-centos-6-chef-12-kitchen chef]#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions