quick for of rehans nginx module with some extra features (will hopefully be merged on the upstream someday).
for some changes I will also create pull requests on the upstream and some will only be available in this for. the
master branch will be kept as is and the development will be continued on the main-c33s branch.
to use this fork, add this to your PUPPETFILE
mod 'rehan-nginx',
:git => 'https://github.com/c33s/puppet-nginx.git',
:branch => 'main-c33s'
- allow to change the
nginx.conftemplate via hiera - allow to define content or source for
nginx::resource::config - added
nginx::resource::snippet - added default debian directory structure
A Puppet module to install, configure and deploy the latest Nginx webserver from stable or mainline (development) branch.
A puppet module for managing the installation and configuration of Nginx. This module installs and configures the nginx
package and allows configuration of vhosts and the webproxy itself. The main objective of this module is to minimize
changes to the default install of nginx package. It tries to give you maximum flexibility by providing vhost resource
that can be used to provide a complete file.
Where possible, this module can be used to ensure the nginx installation is up to date with latest upstream release branches of nginx. Currently, this feature is supported for the following OSes:
- Ubuntu (stable: ppa:nginx/stable, mainline: ppa:nginx/development )
In order to install rehan-nginx, run the following command:
$ puppet module install rehan-nginxThe module does expect all the data to be provided through 'Hiera'. See Usage for examples on how to configure it.
This module is designed to be as clean and compliant with latest puppet code guidelines.
A basic install with the defaults would be:
contain nginxOr the PKI Server using the parameters:
class{ 'nginx':
repo_manage => true,
repo_branch => 'stable',
package_ensure => 'latest',
package_name => 'nginx',
package_extras => [],
service_manage => true,
service_enable => true,
service_ensure => 'running',
service_name => 'nginx',
install_location => '/etc/nginx',
firewall_manage => false,
enabled_sites_manage => false,
configs => hiera_hash('nginx::configs', {}),
vhosts => hiera_hash('nginx::vhosts', {}),
}- repo_manage: Manage the upstream repository on supported OSes. The default value is
true. - repo_branch: The upstream repo branch can be
stableormainline. The default value isstable. - package_ensure: Ensure the nginx package is installed. The default value is
latest. - package_name: Nginx package name. The default is
nginx. - package_extras: Any extra packages required along with nginx. The default is an empty array.
- service_enable: Enables the nginx service at boot. The default is
true. - service_ensure: Controls the nginx service. The default is
running. - service_manage: Controls if this module should manage the nginx service. The default is
true. - service_name: Nginx service name. The default is
nginx. - install_location: The install location for nginx. The default is
/etc/nginx. - firewall_manage: Manage the firewall for port
80and443ifpuppetlabs-firewallmodule is used. The default isfalse. - enabled_sites_manage: If set to true, the
/etc/nginx/sites-enabledwill be purged and only managed vhosts will be maintained. - configs: The hash value for config files that will be dropped in
/etc/nginx/conf.d. Seenginx::resource::configfor details. - vhosts: The hash value for virtual hosts files to be dropped in
/etc/nginx/sites-available. Seenginx::resource::vhostfor details.
All of this data can be provided through Hiera.
YAML
nginx::repo_manage: true
nginx::repo_branch: 'stable'
nginx::package_ensure: 'latest'
nginx::package_name: 'nginx'
nginx::service_manage: true
nginx::service_enable: true
nginx::service_ensure: 'running'
nginx::service_name: 'nginx'
nginx::install_location: '/etc/nginx'
nginx::firewall_manage: false
nginx::enabled_sites_manage: false
nginx::configs:
logstash_format:
source: 'puppet:///modules/webproxy/logstash_format.conf'
nginx::vhosts:
'example.com':
enabled: true
source: 'puppet:///modules/webproxy/example.com'Note: The above config assumes that you have a module called webproxy with a files directoy containing the static files.
This resource allows creation of a configuration file under /etc/nginx/conf.d.
Usage:
nginx::resource::config { 'logstash_format':
source => 'puppet:///modules/webproxy/logstash_format.conf',
}- source a file in a puppet module.
This resource allows creation of a virtual host file under /etc/nginx/sites-available.
Usage:
nginx::resource::vhost { 'example.com':
enabled => true,
source => 'puppet:///modules/webproxy/example.com',
}or with a template:
nginx::resource::vhost { 'example.com':
enabled => true,
content => template('webproxy/example.erb'),
}- source a file in a puppet module. It is not possible to combine this option with content.
- content Content of the vhost file. It is not possible to combine this option with source.
- enabled Creates a link under
/etc/nginx/sites-enabled.
You can submit pull requests and create issues through the official page of this module on GitHub. Please do report any bug and suggest new features/improvements.