• Stars
    star
    468
  • Rank 93,767 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 13 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Puppet Module to manage NGINX on various UNIXes

NGINX module for Puppet

Build Status Code Coverage Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores

This module was migrated from James Fryman [email protected] to Vox Pupuli.

INSTALLING OR UPGRADING

This module manages NGINX configuration.

Requirements

  • Puppet 4.6.1 or later. Puppet 3 was supported up until release 0.6.0.
  • apt is now a soft dependency. If your system uses apt, you'll need to configure an appropriate version of the apt module. Version 4.4.0 or higher is recommended because of the proper handling of apt-transport-https.

Additional Documentation

Install and bootstrap an NGINX instance

include nginx

A simple reverse proxy

nginx::resource::server { 'kibana.myhost.com':
  listen_port => 80,
  proxy       => 'http://localhost:5601',
}

A virtual host with static content

nginx::resource::server { 'www.puppetlabs.com':
  www_root => '/var/www/www.puppetlabs.com',
}

A more complex proxy example

nginx::resource::upstream { 'puppet_rack_app':
  members => {
    'localhost:3000' => {
      server => 'localhost',
      port   => 3000,
      weight => 1,
    },
    'localhost:3001' => {
      server => 'localhost',
      port   => 3001,
      weight => 1,
    },
    'localhost:3002' => {
      server => 'localhost',
      port   => 3002,
      weight => 2,
      },
  },
}

nginx::resource::server { 'rack.puppetlabs.com':
  proxy => 'http://puppet_rack_app',
}

Add a smtp proxy

class { 'nginx':
  mail => true,
}

nginx::resource::mailhost { 'domain1.example':
  auth_http       => 'server2.example/cgi-bin/auth',
  protocol        => 'smtp',
  listen_port     => 587,
  ssl_port        => 465,
  starttls        => 'only',
  xclient         => 'off',
  proxy_protocol  => 'off',
  proxy_smtp_auth => 'off',
  ssl             => true,
  ssl_cert        => '/tmp/server.crt',
  ssl_key         => '/tmp/server.pem',
}

Convert upstream members from Array to Hash

The datatype Array for members of a nginx::resource::upstream is replaced by a Hash. The following configuration is no longer valid:

nginx::resource::upstream { 'puppet_rack_app':
  members => {
    'localhost:3000',
    'localhost:3001',
    'localhost:3002',
  },
}

From now on, the configuration must look like this:

nginx::resource::upstream { 'puppet_rack_app':
  members => {
    'localhost:3000' => {
      server => 'localhost',
      port   => 3000,
    },
    'localhost:3001' => {
      server => 'localhost',
      port   => 3001,
    },
    'localhost:3002' => {
      server => 'localhost',
      port   => 3002,
    },
  },
}

SSL configuration

By default, creating a server resource will only create a HTTP server. To also create a HTTPS (SSL-enabled) server, set ssl => true on the server. You will have a HTTP server listening on listen_port (port 80 by default) and a HTTPS server listening on ssl_port (port 443 by default). Both servers will have the same server_name and a similar configuration.

To create only a HTTPS server, set ssl => true and also set listen_port to the same value as ssl_port. Setting these to the same value disables the HTTP server. The resulting server will be listening on ssl_port.

Idempotency with nginx 1.15.0 and later

By default, this module might configure the deprecated ssl on directive. When you next run puppet, this will be removed since the nginx_version fact will now be available. To avoid this idempotency issue, you can manually set the base class's nginx_version parameter.

Locations

Locations require specific settings depending on whether they should be included in the HTTP, HTTPS or both servers.

HTTP only server (default)

If you only have a HTTP server (i.e. ssl => false on the server) make sure you don't set ssl => true on any location you associate with the server.

HTTP and HTTPS server

If you set ssl => true and also set listen_port and ssl_port to different values on the server you will need to be specific with the location settings since you will have a HTTP server listening on listen_port and a HTTPS server listening on ssl_port:

  • To add a location to only the HTTP server, set ssl => false on the location (this is the default).
  • To add a location to both the HTTP and HTTPS server, set ssl => true on the location, and ensure ssl_only => false (which is the default value for ssl_only).
  • To add a location only to the HTTPS server, set both ssl => true and ssl_only => true on the location.

HTTPS only server

If you have set ssl => true and also set listen_port and ssl_port to the same value on the server, you will have a single HTTPS server listening on ssl_port. To add a location to this server set ssl => true and ssl_only => true on the location.

Hiera Support

Defining nginx resources in Hiera.

nginx::nginx_upstreams:
  'puppet_rack_app':
    ensure: present
    members:
      'localhost:3000':
        server: 'localhost'
        port: 3000
      'localhost:3001':
        server: 'localhost'
        port: 3001
      'localhost:3002':
        server: 'localhost'
        port: 3002
nginx::nginx_servers:
  'www.puppetlabs.com':
    www_root: '/var/www/www.puppetlabs.com'
  'rack.puppetlabs.com':
    proxy: 'http://puppet_rack_app'
nginx::nginx_locations:
  'static':
    location: '~ "^/static/[0-9a-fA-F]{8}\/(.*)$"'
    server: www.puppetlabs.com
    www_root: /var/www/html
  'userContent':
    location: /userContent
    server: www.puppetlabs.com
    www_root: /var/www/html
nginx::nginx_mailhosts:
  'smtp':
    auth_http: server2.example/cgi-bin/auth
    protocol: smtp
    listen_port: 587
    ssl_port: 465
    starttls: only

A stream syslog UDP proxy

nginx::stream: true

nginx::nginx_cfg_prepend:
  include:
    - '/etc/nginx/modules-enabled/*.conf'

nginx::nginx_streamhosts:
  'syslog':
    ensure:                 'present'
    listen_port:            514
    listen_options:         'udp'
    proxy:                  'syslog'
    proxy_read_timeout:     '1'
    proxy_connect_timeout:  '1'
    raw_append:
      - 'error_log off;'

nginx::nginx_upstreams:
  'syslog':
    context: 'stream'
    members:
      '10.0.0.1:514':
        server: '10.0.0.1'
        port: 514
      '10.0.0.2:514':
        server: '10.0.0.2'
        port: 514
      '10.0.0.3:514':
        server: '10.0.0.3'
        port: 514

Nginx with precompiled Passenger

Example configuration for Debian and RHEL / CentOS (>6), pulling the Nginx and Passenger packages from the Phusion repo. See additional notes in https://github.com/voxpupuli/puppet-nginx/blob/master/docs/quickstart.md

class { 'nginx':
  package_source  => 'passenger',
  http_cfg_append => {
    'passenger_root' => '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini',
  }
}

Here the example for OpenBSD:

class { 'nginx':
  package_flavor => 'passenger',
  service_flags  => '-u'
  http_cfg_append => {
    passenger_root          => '/usr/local/lib/ruby/gems/2.1/gems/passenger-4.0.44',
    passenger_ruby          =>  '/usr/local/bin/ruby21',
    passenger_max_pool_size => '15',
  }
}

Package source passenger will add Phusion Passenger repository to APT sources. For each virtual host you should specify which ruby should be used.

nginx::resource::server { 'www.puppetlabs.com':
  www_root          => '/var/www/www.puppetlabs.com',
  server_cfg_append => {
    'passenger_enabled' => 'on',
    'passenger_ruby'    => '/usr/bin/ruby',
  }
}

Puppet master served by Nginx and Passenger

Virtual host config for serving puppet master:

nginx::resource::server { 'puppet':
  ensure               => present,
  server_name          => ['puppet'],
  listen_port          => 8140,
  ssl                  => true,
  ssl_cert             => '/var/lib/puppet/ssl/certs/example.com.pem',
  ssl_key              => '/var/lib/puppet/ssl/private_keys/example.com.pem',
  ssl_port             => 8140,
  server_cfg_append    => {
    'passenger_enabled'      => 'on',
    'passenger_ruby'         => '/usr/bin/ruby',
    'ssl_crl'                => '/var/lib/puppet/ssl/ca/ca_crl.pem',
    'ssl_client_certificate' => '/var/lib/puppet/ssl/certs/ca.pem',
    'ssl_verify_client'      => 'optional',
    'ssl_verify_depth'       => 1,
  },
  www_root             => '/etc/puppet/rack/public',
  use_default_location => false,
  access_log           => '/var/log/nginx/puppet_access.log',
  error_log            => '/var/log/nginx/puppet_error.log',
  passenger_cgi_param  => {
    'HTTP_X_CLIENT_DN'     => '$ssl_client_s_dn',
    'HTTP_X_CLIENT_VERIFY' => '$ssl_client_verify',
  },
}

Example puppet class calling nginx::server with HTTPS FastCGI and redirection of HTTP

$full_web_path = '/var/www'

define web::nginx_ssl_with_redirect (
  $backend_port         = 9000,
  $php                  = true,
  $proxy                = undef,
  $www_root             = "${full_web_path}/${name}/",
  $location_cfg_append  = undef,
) {
  nginx::resource::server { "${name}.${::domain}":
    ensure              => present,
    www_root            => "${full_web_path}/${name}/",
    location_cfg_append => {
      'rewrite' => '^ https://$server_name$request_uri? permanent'
    }โ€š,
  }

  if !$www_root {
    $tmp_www_root = undef
  } else {
    $tmp_www_root = $www_root
  }

  nginx::resource::server { "${name}.${::domain} ${name}":
    ensure                => present,
    listen_port           => 443,
    www_root              => $tmp_www_root,
    proxy                 => $proxy,
    location_cfg_append   => $location_cfg_append,
    index_files           => [ 'index.php' ],
    ssl                   => true,
    ssl_cert              => '/path/to/wildcard_mydomain.crt',
    ssl_key               => '/path/to/wildcard_mydomain.key',
  }


  if $php {
    nginx::resource::location { "${name}_root":
      ensure          => present,
      ssl             => true,
      ssl_only        => true,
      server           => "${name}.${::domain} ${name}",
      www_root        => "${full_web_path}/${name}/",
      location        => '~ \.php$',
      index_files     => ['index.php', 'index.html', 'index.htm'],
      proxy           => undef,
      fastcgi         => "127.0.0.1:${backend_port}",
      fastcgi_script  => undef,
      location_cfg_append => {
        fastcgi_connect_timeout => '3m',
        fastcgi_read_timeout    => '3m',
        fastcgi_send_timeout    => '3m'
      }
    }
  }
}

Add custom fastcgi_params

nginx::resource::location { "some_root":
  ensure         => present,
  location       => '/some/url',
  fastcgi        => "127.0.0.1:9000",
  fastcgi_param  => {
    'APP_ENV' => 'local',
  },
}

Call class web::nginx_ssl_with_redirect

web::nginx_ssl_with_redirect { 'sub-domain-name':
    backend_port => 9001,
  }

More Repositories

1

json-schema

Ruby JSON Schema Validator
Ruby
1,447
star
2

puppetboard

Web frontend for PuppetDB
Python
698
star
3

hiera-eyaml

A backend for Hiera that provides per-value asymmetric encryption of sensitive data
Ruby
528
star
4

puppet-elasticsearch

Elasticsearch Puppet module
Ruby
406
star
5

beaker

Puppet Acceptance Testing Harness
Ruby
368
star
6

puppet-jenkins

Puppet module for Jenkins
Ruby
276
star
7

puppet-python

Puppet module for installing and managing Python, pip, virtualenvs and Gunicorn virtual hosts.
Ruby
197
star
8

puppet-logstash

Puppet module to manage Logstash
Puppet
192
star
9

puppet-rabbitmq

RabbitMQ Puppet Module
Ruby
174
star
10

onceover

Your gateway drug to automated infrastructure testing with Puppet
Ruby
142
star
11

puppet-mcollective

MCollective Server and Client Puppet Module
Ruby
122
star
12

puppet-consul

A Puppet Module to Manage Consul
Ruby
120
star
13

puppet-openvpn

OpenVPN module for puppet including client config/cert creation
Ruby
113
star
14

puppet-nodejs

Puppet module to install nodejs and global npm packages
Ruby
112
star
15

modulesync

Synchronize common files across your Git repositories.
Ruby
101
star
16

vagrant-librarian-puppet

A Vagrant plugin to install Puppet modules using Librarian-Puppet.
Ruby
101
star
17

puppet-r10k

Setup and configure r10k for use with git based environments in puppet
Ruby
98
star
18

pypuppetdb

Python library for working with the PuppetDB API
Python
93
star
19

puppet-mongodb

mongodb installation
Ruby
92
star
20

puppet-ghostbuster

๐Ÿ‘ป Dead code detector for Puppet
Ruby
89
star
21

puppet-letsencrypt

A Puppet module to install the Letsencrypt client and request certificates.
Ruby
86
star
22

puppet-php

Generic Puppet module to manage PHP on many platforms
Puppet
85
star
23

puppet-mode

Edit Puppet manifests with GNU Emacs 24
Emacs Lisp
77
star
24

puppet-gitlab

Puppet module to manage Gitlab (Omnibus)
Puppet
74
star
25

puppet-postfix

Puppet postfix module
HTML
72
star
26

puppet-collectd

Collectd module for Puppet
Ruby
70
star
27

puppet-syntax

Syntax checks for Puppet manifests and templates
Ruby
68
star
28

puppet-blacksmith

Ruby Gem with Puppet Module utilities
Ruby
68
star
29

puppet-network

Types and providers to manage network interfaces
Ruby
68
star
30

puppet-augeasproviders

Alternative Augeas-based providers for Puppet
Ruby
65
star
31

puppet-system

Manage Linux system resources and services from hiera configuration
Puppet
64
star
32

puppet-jira

Atlassian JIRA Puppet Module
Ruby
61
star
33

puppet-prometheus

Puppet module for prometheus
Puppet
60
star
34

puppet-archive

Compressed archive file download and extraction with native types/providers for Windows and Unix
Ruby
59
star
35

beaker-rspec

beaker-rspec is a bridge between the puppet acceptance test harness
Ruby
58
star
36

rspec-puppet-facts

Simplify your unit tests by looping on every supported Operating System and populating facts.
Ruby
58
star
37

puppet-puppetboard

Puppet module to install and manage puppetboard
Puppet
53
star
38

puppet-staging

โ›”๏ธ Deprecated in favor of puppet-archive
Ruby
51
star
39

puppet-pxe

Puppet module for deploying a PXE boot server
Puppet
49
star
40

hiera-eyaml-gpg

GPG encryption backend for the hiera-eyaml module
Ruby
49
star
41

puppet-systemd

Puppet module to manage systemd
Ruby
49
star
42

puppet-selinux

Puppet Module to manage SELinux on RHEL machines
Ruby
49
star
43

puppet-keepalived

Puppet Module to manage Keepalived
Ruby
48
star
44

puppet-prometheus_reporter

A prometheus Puppet reports exporter for Puppet
Ruby
48
star
45

puppet-iis

Module to mange IIS with Puppet
Ruby
46
star
46

puppet-corosync

Sets up and manages Corosync.
Ruby
45
star
47

puppet-dhcp

Puppet module for deploying dhcp
Ruby
42
star
48

puppet-epel

Setup/configure EPEL (extra repository for enterprise linux) with Puppet
Ruby
41
star
49

puppet-redis

Puppet Module to manage Redis
Ruby
40
star
50

puppet-openssl

Puppet OpenSSL module
Ruby
39
star
51

puppet-pkgng

A Puppet package provider for FreeBSD's PkgNG package manager.
Ruby
39
star
52

puppet-firewalld

Puppet module for managing firewalld
Ruby
39
star
53

puppet-splunk

Manage Splunk servers and forwarders using Puppet
Ruby
39
star
54

puppet-rundeck

Module for managing the installatation and configuration of the rundeck orchestration tool
Ruby
38
star
55

puppet-openldap

Manage OpenLDAP with Puppet
Ruby
35
star
56

puppet-vmwaretools

Puppet module to manage VMware Operating System Specific Packages for VMware tools installation.
Puppet
35
star
57

puppet-snmp

Puppet module to manage Net-SNMP.
Ruby
34
star
58

puppet-unattended_upgrades

Unattended-upgrades for APT
Ruby
33
star
59

puppet-dnsquery

DNS query functions for Puppet
Ruby
32
star
60

puppet-hiera

Hiera hierarchy module for templating `hiera.yaml`
Ruby
32
star
61

puppet-kafka

The kafka module for managing the installation and configuration of Apache Kafka
Puppet
30
star
62

puppet-fail2ban

This module installs, configures and manages the Fail2ban service.
Ruby
30
star
63

ra10ke

Rake tasks related to R10K and Puppetfile
Ruby
29
star
64

puppet-wildfly

Puppet module to install, configure and manage Wildfly (8/9/10+), JBoss EAP (6.1+/7.0+) and some Wildfly based products like apiman, Keycloak and Infinispan.
Ruby
29
star
65

puppet-windowsfeature

Library that uses ServerAdministration api that comes with Windows Server 2008 and Windows Server 2012 to add / remove windows features
Ruby
29
star
66

puppet-catalog-diff-viewer

A viewer for the puppet-catalog-diff tool
JavaScript
28
star
67

puppet-unbound

Puppet module for deploying the swiss-army of DNS, Unbound
Ruby
28
star
68

metadata-json-lint

Tool to check the validity of Puppet metadata.json files
Ruby
27
star
69

hiera-file

File backend for Hiera
Ruby
26
star
70

puppet-vault_lookup

Ruby
25
star
71

puppetdb-ruby

Ruby client library for interacting with PuppetDB API
Ruby
24
star
72

puppet-alternatives

Manage Debian alternatives links
Ruby
24
star
73

puppet-telegraf

A Puppet module for installing and configuring InfluxData's Telegraf
Ruby
24
star
74

puppet-healthcheck

Puppet resources to evaluate the health and status of things.
Ruby
22
star
75

puppet-puppetserver

Puppet module for puppetserver
Ruby
21
star
76

puppet-confluence

A puppet module to install confluence
Ruby
20
star
77

puppet-drbd

Basic module for configuring active-passive drbd resources
Puppet
20
star
78

puppet-stash

A puppet module to install atlassian stash
Ruby
19
star
79

puppet-kmod

manage kernel module with puppet
Ruby
18
star
80

puppet-mrepo

Puppet module for creating and managing RPM based repository mirrors.
Puppet
17
star
81

puppet-ssh_keygen

Generation of ssh keys with ssh-keygen
Ruby
17
star
82

puppet-windows_firewall

puppet module for configuring the windows firewall
Ruby
17
star
83

puppet-nomad

Puppet module for managing Nomad
Ruby
16
star
84

puppet-gluster

Create and manage Gluster pools, volumes, and mounts
Ruby
16
star
85

puppet-kibana

Kibana Puppet module by Elastic.
Ruby
16
star
86

puppet-filemapper

Map files to puppet resources and back
Ruby
15
star
87

puppet-proxysql

Puppet module to configure ProxySQL
Ruby
15
star
88

puppet-cron

Puppet module to manage cron jobs via /etc/cron.d
Ruby
14
star
89

puppet-tea

Puppet 4.6 Types: Abstracted & Extracted
Ruby
14
star
90

puppet-ca_cert

A puppet module for managing (non-system) CA certificates.
Ruby
14
star
91

puppet-minecraft

Puppet - Minecraft: Separately maintained fork of brannan's puppet-module-minecraft
Ruby
14
star
92

puppet-chrony

Puppet module for Chrony with Systemd
Ruby
13
star
93

puppet-smokeping

Puppet module to install and configure smokeping. Including target and slave definition
Puppet
13
star
94

puppet-cassandra

Installs Cassandra & DataStax Agent on RHEL/Ubuntu/Debian.
Ruby
13
star
95

puppet-googleauthenticator

Google-authenticator module for Puppet
Puppet
13
star
96

puppet-bareos

Puppet Module to manage bareos
Puppet
13
star
97

puppet-misp

This module installs and configures MISP (Malware Information Sharing Platform)
HTML
13
star
98

puppet_webhook

Sinatra-based application that triggers puppet-related commands from VCS Webhook calls
Ruby
13
star
99

puppet-extlib

This module provides functions that are out of scope for stdlib.
Ruby
13
star
100

puppet-gitlab_ci_runner

Module to mange gitlab CI runners. Extracted from https://github.com/voxpupuli/puppet-gitlab
Ruby
13
star