Skip to content

Commit

Permalink
Merge pull request #29 from rehanone/develop/update-conf-template
Browse files Browse the repository at this point in the history
- Create nginx.conf from template file.
  • Loading branch information
rehanone authored Jul 9, 2020
2 parents ab876b8 + 174cea2 commit f53482b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
14 changes: 13 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

assert_private("Use of private class ${name} by ${caller_module_name}")

file { "${nginx::install_location}/sites-enabled":
file { "${nginx::install_location}/nginx.conf":
ensure => file,
content => epp("${module_name}/nginx.conf.epp",
{
'install_location' => $nginx::install_location,
}
),
}
-> file { "${nginx::install_location}/sites-available":
ensure => directory,
recurse => true,
}
-> file { "${nginx::install_location}/sites-enabled":
ensure => directory,
purge => $nginx::enabled_sites_manage,
recurse => true,
Expand Down
14 changes: 14 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
require apt
case $nginx::repo_branch {
'mainline': {
if $::facts[os][name] == 'Ubuntu' {
$ppa = 'ppa:nginx/development'
apt::ppa { $ppa:
ensure => absent,
}
}

apt::source { "nginx-${nginx::repo_branch}":
ensure => $nginx::repo_ensure,
location => $nginx::repo_sources[mainline],
Expand All @@ -32,6 +39,13 @@
}
}
default: {
if $::facts[os][name] == 'Ubuntu' {
$ppa = 'ppa:nginx/stable'
apt::ppa { $ppa:
ensure => absent,
}
}

apt::source { "nginx-${nginx::repo_branch}":
ensure => $nginx::repo_ensure,
location => $nginx::repo_sources[mainline],
Expand Down
37 changes: 37 additions & 0 deletions templates/nginx.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%- | String $install_location
| -%>
# HEADER: This file is managed by Puppet; changes may be overwritten.

user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include <%= $install_location %>/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;


include <%= $install_location %>/conf.d/*.conf;
include <%= $install_location %>/sites-enabled/*;
}
3 changes: 3 additions & 0 deletions templates/nginx.conf.render.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

puppet epp render nginx.conf.epp --values '{ install_location => "/etc/nginx" }'

0 comments on commit f53482b

Please sign in to comment.