Skip to content

Commit 1d11ee0

Browse files
Final Commit after adding ca and ssl
Signed-off-by: paragchak-sumo <[email protected]>
1 parent 3137514 commit 1d11ee0

File tree

148 files changed

+5615
-3532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+5615
-3532
lines changed

.pdkignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
.project
2626
.envrc
2727
/inventory.yaml
28-
/appveyor.yml
2928
/.fixtures.yml
3029
/Gemfile
3130
/.gitattributes

.sync.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,5 @@ spec/spec_helper.rb:
2727
paths: *ignorepaths
2828
Gemfile:
2929
unmanaged: true
30-
appveyor.yml:
31-
unmanaged: true
3230
.rspec:
3331
unmanaged: true

REFERENCE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4799,7 +4799,7 @@ Default value: `/etc/sensu/ssl/ca.crt`
47994799

48004800
URL to use with 'sensuctl configure'
48014801

4802-
Default value: `http://127.0.0.1:8080`
4802+
Default value: `https://127.0.0.1:8080`
48034803

48044804
##### <a name="-sensu_user--name"></a>`name`
48054805

@@ -5172,6 +5172,12 @@ Data type: `Optional[String[1]]`
51725172

51735173
The namespace for the agent, default is 'default'
51745174

5175+
##### `use_ssl`
5176+
5177+
Data type: `Optional[Boolean]`
5178+
5179+
Whether to use SSL for backend API connections, default is true
5180+
51755181
##### `output`
51765182

51775183
Data type: `Optional[Boolean]`

appveyor.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,74 @@
11
$password = 'sensu'
22

3+
class { 'sensu':
4+
use_ssl => true,
5+
ssl_ca_source => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem',
6+
api_host => 'sensu-backend',
7+
}
8+
39
class { 'sensu::agent':
4-
backends => ['sensu-backend:8081'],
10+
backends => ['sensu-backend:8081'],
11+
config_hash => {
12+
'keepalive-interval' => 5,
13+
},
514
}
615

716
class { 'postgresql::globals':
8-
manage_package_repo => true,
9-
version => '11',
17+
manage_package_repo => false,
18+
}
19+
20+
# Ensure data directory is ready for initdb
21+
exec { 'clean_postgres_datadir_if_incomplete':
22+
command => '/bin/rm -rf /var/lib/pgsql/data/*',
23+
onlyif => '/bin/bash -c "[ -d /var/lib/pgsql/data ] && [ ! -f /var/lib/pgsql/data/PG_VERSION ]"',
24+
require => Class['postgresql::server::install'],
25+
before => Class['postgresql::server::initdb'],
1026
}
1127

1228
class { 'postgresql::server':
1329
listen_addresses => '*',
1430
}
1531

32+
# Copy SSL key for PostgreSQL to use with the default name
33+
# Must be created AFTER initdb but BEFORE service starts
1634
file { 'postgresql_ssl_key_file':
17-
ensure => 'file',
18-
path => "${postgresql::server::datadir}/${trusted['certname']}.pem",
19-
source => "/etc/puppetlabs/puppet/ssl/private_keys/${trusted['certname']}.pem",
20-
owner => 'postgres',
21-
group => 'postgres',
22-
mode => '0600',
23-
}
24-
25-
postgresql::server::db { 'sensu':
26-
user => 'sensu',
27-
password => postgresql::postgresql_password('sensu', $password),
28-
}
29-
30-
postgresql::server::pg_hba_rule { 'allow access to sensu database':
31-
description => 'Open up postgresql for access to sensu from 0.0.0.0/0',
32-
type => 'host',
33-
database => 'sensu',
34-
user => 'sensu',
35-
address => '0.0.0.0/0',
36-
auth_method => 'password',
35+
ensure => 'file',
36+
path => "${postgresql::server::datadir}/server.key",
37+
source => '/etc/puppetlabs/puppet/ssl/private_keys/sensu-agent_key.pem',
38+
owner => 'postgres',
39+
group => 'postgres',
40+
mode => '0600',
41+
require => Class['postgresql::server::initdb'],
42+
before => Class['postgresql::server::service'],
3743
}
3844

3945
postgresql::server::config_entry { 'ssl':
4046
value => 'on',
4147
}
4248

4349
postgresql::server::config_entry { 'ssl_cert_file':
44-
value => "/etc/puppetlabs/puppet/ssl/certs/${trusted['certname']}.pem",
50+
value => '/etc/puppetlabs/puppet/ssl/ca/signed/sensu-agent.pem',
4551
}
4652

4753
postgresql::server::config_entry { 'ssl_key_file':
48-
value => "${trusted['certname']}.pem",
54+
value => 'server.key',
4955
require => File['postgresql_ssl_key_file'],
5056
}
5157

5258
postgresql::server::config_entry { 'ssl_ca_file':
53-
value => '/etc/puppetlabs/puppet/ssl/certs/ca.pem',
59+
value => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem',
60+
}
61+
62+
postgresql::server::db { 'sensu':
63+
user => 'sensu',
64+
password => postgresql::postgresql_password('sensu', $password),
5465
}
5566

56-
postgresql::server::config_entry { 'ssl_crl_file':
57-
value => '/etc/puppetlabs/puppet/ssl/crl.pem',
67+
postgresql::server::pg_hba_rule { 'allow access to sensu database':
68+
description => 'Open up postgresql for access to sensu from 0.0.0.0/0',
69+
type => 'host',
70+
database => 'sensu',
71+
user => 'sensu',
72+
address => '0.0.0.0/0',
73+
auth_method => 'password',
5874
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
$password = 'sensu'
22

33
class { 'sensu':
4-
use_ssl => false,
4+
use_ssl => true,
5+
ssl_ca_source => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem',
6+
api_host => 'sensu-backend',
57
}
68
include sensu::cli
79
class { 'sensu::agent':
810
backends => ['sensu-backend:8081'],
911
}
1012
class { 'sensu::backend':
11-
datastore => 'postgresql',
12-
manage_postgresql_db => false,
13-
postgresql_host => 'sensu-agent',
14-
postgresql_password => $password,
15-
postgresql_ssl_ca_source => $sensu::ssl_ca_source,
16-
postgresql_ssl_crl_source => $facts['puppet_hostcrl'],
17-
postgresql_ssl_cert_source => $facts['puppet_hostcert'],
18-
postgresql_ssl_key_source => $facts['puppet_hostprivkey'],
13+
ssl_cert_source => '/etc/puppetlabs/puppet/ssl/ca/signed/sensu-backend.pem',
14+
ssl_key_source => '/etc/puppetlabs/puppet/ssl/private_keys/sensu-backend_key.pem',
15+
datastore => 'postgresql',
16+
manage_postgresql_db => false,
17+
postgresql_host => 'sensu-agent',
18+
postgresql_password => $password,
1919
}

examples/ssl-backend.pp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Example of Sensu backend with SSL enabled
2+
#
3+
# This example demonstrates how to configure a Sensu backend with SSL/TLS
4+
# using the test certificates from /etc/puppetlabs/puppet/ssl/
5+
6+
class { 'sensu':
7+
use_ssl => true,
8+
ssl_ca_source => '/etc/puppetlabs/puppet/ssl/ca/ca_crt.pem',
9+
api_host => 'sensu-backend',
10+
}
11+
12+
class { 'sensu::backend':
13+
ssl_cert_source => '/etc/puppetlabs/puppet/ssl/ca/signed/sensu-backend.pem',
14+
ssl_key_source => '/etc/puppetlabs/puppet/ssl/private_keys/sensu-backend_key.pem',
15+
}
16+
17+
include sensu::cli

lib/puppet/provider/sensu_bonsai_asset/sensuctl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def asset_add(version)
8383
opts[:custom_environment]['no_proxy'] = resource[:bonsai_no_proxy] if resource[:bonsai_no_proxy]
8484
end
8585
begin
86-
sensuctl(cmd, opts)
86+
sensuctl(cmd, **opts)
8787
rescue Exception => e
8888
raise Puppet::Error, "#{cmd.join(' ')} failed\nError message: #{e.message}"
8989
end

lib/puppet/provider/sensuctl.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def convert_boolean_property_value(value)
6565
self.class.convert_boolean_property_value(value)
6666
end
6767

68-
def self.sensuctl(args, failonfail: nil, combine: nil, **_kwargs)
68+
def self.sensuctl(args, failonfail: nil, combine: nil, custom_environment: nil, **_kwargs)
6969
sensuctl_cmd = which('sensuctl')
7070
if ! path.nil?
7171
cmd = [path] + args
@@ -75,6 +75,9 @@ def self.sensuctl(args, failonfail: nil, combine: nil, **_kwargs)
7575
opts = {}
7676
opts[:failonfail] = failonfail.nil? ? true : failonfail
7777
opts[:combine] = combine.nil? ? true : combine
78+
if custom_environment
79+
opts[:custom_environment] = custom_environment
80+
end
7881
execute(cmd, opts)
7982
end
8083
def sensuctl(cmd_args, **opts)

lib/puppet/type/sensu_user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def should_to_s(newvalue)
9999

100100
newparam(:configure_url) do
101101
desc "URL to use with 'sensuctl configure'"
102-
defaultto 'http://127.0.0.1:8080'
102+
defaultto 'https://127.0.0.1:8080'
103103
end
104104

105105
newparam(:configure_trusted_ca_file) do

0 commit comments

Comments
 (0)