voxpupuli / puppet-nginx

Puppet Module to manage NGINX on various UNIXes
https://forge.puppet.com/puppet/nginx
MIT License
471 stars 881 forks source link

map resource - using only include_files results in error #1242

Open bostrowski13 opened 6 years ago

bostrowski13 commented 6 years ago

Target machine: RHEL 7.x PE 2018.1.2 on RHEL 7.x Module Version: 'puppet-nginx', '0.13.0'

Trying to deploy a load balancer for in front of a k8s cluster.

the issue i'm having is that the "map" resource is throwing:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Nginx::Resource::Map[nginx_http_redirect_map]: expects a value for parameter 'string' expects a value for parameter 'mappings' (file: /etc/puppetlabs/code/environments/feature_rancher_nginx_role/site/profile/manifests/company/webserver/loadbalancer.pp, line: 30) on node server1

  class{'nginx':
    manage_repo    => true,
    package_source => 'nginx-stable',
  }
  nginx::resource::upstream{$platform_shortname:
    members => $upstream_members,
    require => Class['nginx'],
  }
  file{'nginx_http_redirect_file':
    ensure => file,
    path   => '/etc/nginx/conf.d/redirections.map',
    source => 'puppet:///modules/profile/nginx/redirections.map',
  }
  nginx::resource::map{ 'nginx_http_redirect_map':
    include_files => ['/etc/nginx/conf.d/redirections.map'],
    require       => [
      File['nginx_http_redirect_file'],
      Nginx::Resource::Upstream[$platform_shortname],
    ],
  }

From the example in the manifest for resource, it looks like i can just use the "include_files" param, but its throwing he above error.

# Sample Usage (using external include)
#
# nginx::resource::map { 'redirections':
#
#    include_files => [ '/etc/nginx/conf.d/redirections.map']
#
# }
bostrowski13 commented 6 years ago

worth noting, this is the contents of my map file.

map $http_upgrade $connection_upgrade {
    default Upgrade;
    ''      close;
}
janorn commented 5 years ago

Here is a config that should do what you want. Without having to add a file to the puppet module.

Puppet code:

nginx::resource::map{ 'connection_upgrade':
  ensure   => present,
  string   => '$http_upgrade'
  default  => upgrade,
  mappings => {
    "''" => close
  }
}

Hiera:

nginx::string_mappings:
  connection_upgrade:
    default: upgrade
    string: $http_upgrade
    mappings:
      "''": close
butlerfr commented 1 year ago

Hello I have exactly the same issue. I just want to include a file with redirections pattern inside it (like 1800 redirections) according to the doc it's possible but the resource will not allow it : https://github.com/voxpupuli/puppet-nginx/blob/master/manifests/resource/map.pp#L68

this line Variant[Array, Hash] $mappings, should be: Optional[Variant[Array, Hash]] $mappings,