Created
December 10, 2018 17:22
-
-
Save TJM/2232d67e3e62adbf17bea753d61e7342 to your computer and use it in GitHub Desktop.
Puppet Profile for nginxplus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Class: profile::nginxplus | |
# | |
class profile::nginxplus ( | |
Optional[String] $repo_cert = undef, | |
Optional[String] $repo_key = undef, | |
Boolean $manage_repo = true, | |
Boolean $enable_dashboard = true, | |
Boolean $dashboard_readonly = true, | |
Integer $dashboard_port = 8080, | |
) { | |
if $manage_repo { | |
yumrepo { 'nginx-plus': | |
baseurl => "https://plus-pkgs.nginx.com/centos/${::operatingsystemmajrelease}/\$basearch/", | |
descr => 'nginx-plus repo', | |
enabled => '1', | |
gpgcheck => '0', | |
priority => '1', | |
sslclientcert => '/etc/ssl/nginx/nginx-repo.crt', | |
sslclientkey => '/etc/ssl/nginx/nginx-repo.key', | |
before => Package['nginx'], | |
} | |
if $repo_cert or $repo_key { | |
file { '/etc/ssl/nginx': | |
ensure => directory, | |
mode => '0750', | |
owner => 'root', | |
group => 'root', | |
} | |
} | |
if $repo_cert { | |
file { '/etc/ssl/nginx/nginx-repo.crt': | |
ensure => present, | |
mode => '0640', | |
owner => 'root', | |
group => 'root', | |
content => $repo_cert, | |
before => Yumrepo['nginx-release'], | |
} | |
} | |
if $repo_key { | |
file { '/etc/ssl/nginx/nginx-repo.key': | |
ensure => present, | |
mode => '0640', | |
owner => 'root', | |
group => 'root', | |
content => $repo_key, | |
before => Yumrepo['nginx-release'], | |
} | |
} | |
} | |
class{'nginx': | |
manage_repo => false, | |
package_name => 'nginx-plus', | |
} | |
if $enable_dashboard { | |
$dashboard_redirect = {'return' => '301 /dashboard.html'} | |
$dashboard_api = $dashboard_readonly ? { | |
true => { 'api' => 'write=off' }, | |
false => { 'api' => 'write=on' }, | |
} | |
nginx::resource::server{'nginxplus_dashboard': | |
listen_port => $dashboard_port, | |
location_custom_cfg => $dashboard_redirect, | |
} | |
nginx::resource::location{'nginxplus_dashboard/dashboard.html': | |
location => '/dashboard.html', | |
server => 'nginxplus_dashboard', | |
www_root => '/usr/share/nginx/html', | |
} | |
nginx::resource::location{'nginxplus_dashboard/status.html': | |
location => '/status.html', | |
server => 'nginxplus_dashboard', | |
location_custom_cfg => $dashboard_redirect, | |
} | |
nginx::resource::location{'nginxplus_dashboard/api': | |
location => '/api', | |
server => 'nginxplus_dashboard', | |
location_custom_cfg => $dashboard_api, | |
# directives limiting access to the API | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment