Skip to content

Commit

Permalink
Merge pull request #18 from level99/nginx-ssl
Browse files Browse the repository at this point in the history
Add nginx ssl support and stop setting default user/pass
  • Loading branch information
dstockman committed Jul 1, 2014
2 parents 5ed4811 + 0f8cc4b commit fc8e630
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,20 @@ stackdriver::plugin::postgres::dbname: '<REQUIRED PARAM>'

### nginx

Configures the nginx plugin on the local host running on port 80.
Configures the nginx plugin on the local host running on port 80 (with authentication).

```yaml
stackdriver::plugin::nginx::url: 'http://127.0.0.1/nginx_status'
stackdriver::plugin::nginx::user: 'stackdriver'
stackdriver::plugin::nginx::password: 'Eef3haeziqu3j'
stackdriver::plugin::nginx::url: 'http://127.0.0.1/nginx_status'
```

Configures the nginx plugin on the local host running on port 443 (SSL, no authentication, no verification).

```yaml
stackdriver::plugin::nginx::url: 'https://127.0.0.1/nginx_status'
stackdriver::plugin::nginx::verifypeer: false
stackdriver::plugin::nginx::verifyhost: false
```

### apache
Expand Down
43 changes: 31 additions & 12 deletions manifests/plugin/nginx.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,33 @@
# ---
#
# [*config*]
# - Default - /opt/stackdriver/collectd/etc/collectd.d/nginx.conf
# - Default - /opt/stackdriver/collectd/etc/collectd.d/nginx.conf (string - absolute path)
# - Plugin Configuration File
#
# [*url*]
# - Default - http://127.0.0.1/nginx_status
# - Default - http://127.0.0.1/nginx_status (string - URI)
# - Target server URL
#
# [*user*]
# - Default - stackdriver
# - Default - undef (string)
# - Target user
#
# [*password*]
# - Default - Eef3haeziqu3j
# - Default - undef (string)
# - Target user password
#
# [*verifypeer*]
# - Default - undef (boolean)
# - Enable or disable peer SSL certificate verification
#
# [*verifyhost*]
# - Default - undef (boolean)
# - Enable or disable peer host name verification
#
# [*cacert*]
# - Default - undef (string - absolute path)
# - File that holds one or more SSL certificates
#
# === Usage
# ---
#
Expand All @@ -41,18 +53,25 @@
#
class stackdriver::plugin::nginx(

$config = '/opt/stackdriver/collectd/etc/collectd.d/nginx.conf',
$config = '/opt/stackdriver/collectd/etc/collectd.d/nginx.conf',

$url = 'http://127.0.0.1/nginx_status',
$user = 'stackdriver',
$password = 'Eef3haeziqu3j',
$url = 'http://127.0.0.1/nginx_status',
$user = undef,
$password = undef,
$verifypeer = undef,
$verifyhost = undef,
$cacert = undef,

) {

validate_string ( $config )
validate_string ( $url )
validate_string ( $user )
validate_string ( $password )
validate_absolute_path ( $config )
validate_string ( $url )

if $user != undef { validate_string ( $user ) }
if $password != undef { validate_string ( $password ) }
if $verifypeer != undef { validate_bool ( $verifypeer ) }
if $verifyhost != undef { validate_bool ( $verifyhost ) }
if $cacert != undef { validate_absolute_path ( $cacert ) }

#contain "${name}::install"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ LoadPlugin "nginx"
URL "<%= @url %>"
# If you restricted access to your stats, you can
# set the username and password here
<% if @user -%>
User "<%= @user %>"
<% end -%>

<% if @password -%>
Password "<%= @password %>"
<% end -%>

<% if not @verifypeer.nil? -%>
VerifyPeer <%= @verifypeer %>
<% end -%>

<% if not @verifyhost.nil? -%>
VerifyHost <%= @verifyhost %>
<% end -%>

<% if @cacert -%>
CACert "<%= @cacert %>"
<% end -%>

</Plugin>

0 comments on commit fc8e630

Please sign in to comment.