Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

location_cfg_append can now acccept an array of values #147

Closed
wants to merge 5 commits into from

Conversation

jtreminio
Copy link

Previously, location_cfg_append would only accept a single value, now you can pass an array:

$fastcgi_param = [
  'PATH_INFO $fastcgi_path_info',
  'PATH_TRANSLATED $document_root$fastcgi_path_info',
  'SCRIPT_FILENAME $document_root$fastcgi_script_name',
]

nginx::resource::location { "${server_name}-php":
  ensure              => present,
  vhost               => $server_name,
  location            => '~ \.php$',
  proxy               => undef,
  try_files           => ['$uri', '$uri/', "/${try_files}?\$args"],
  www_root            => $www_root,
  location_cfg_append => {
    'fastcgi_split_path_info' => '^(.+\.php)(/.+)$',
    'fastcgi_param'           => $fastcgi_param,
    'fastcgi_pass'            => $fastcgi_pass,
    'fastcgi_index'           => 'index.php',
    'include'                 => 'fastcgi_params'
  },
  notify              => Class['nginx::service'],
}

@jtreminio jtreminio closed this Oct 7, 2013
@jtreminio jtreminio reopened this Oct 7, 2013
@@ -3,6 +3,12 @@
<%= key %> <%= value %>;<% end -%><% end -%>
alias <%= @location_alias %>;
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;<% end -%><% end -%>
<% if value.is_a? Array -%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about casting value as an Array with Array()? That way you can avoid the if then dance here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with all the other examples.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't even need to do that much. If value is a String, <% value.each do |sub| %> will just loop through it once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no each method on a string object in Ruby 1.9.1 and higher though. http://ruby-doc.org/core-1.9.1/String.html

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. In that case, I think you can make it an array like so: <% Array(value).each do |sub| %>

@jtreminio
Copy link
Author

@jfryman I'm coming from a non-ruby world, can you show me a quick, proper example so I can commit?

Thanks!

@@ -63,7 +63,6 @@
exec { 'apt_get_update_for_nginx':
command => '/usr/bin/apt-get update',
timeout => 240,
returns => [ 0, 100 ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be removed for this PR.

@jfryman
Copy link
Contributor

jfryman commented Jun 24, 2014

Way old. Thanks for taking a pass at this... going to revisit when 🕐 allows. Please reopen and rebase if you wanna take another pass at this.

@jfryman jfryman closed this Jun 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants