Skip to content

Commit 1f43674

Browse files
authored
Merge pull request #161 from github/kpaulisse-puppetdb-ssl-basicauth
Add puppetdb basic auth, update change log and docs
2 parents f97f947 + e7b74df commit 1f43674

File tree

6 files changed

+61
-16
lines changed

6 files changed

+61
-16
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.0
1+
1.5.1

doc/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
<th>Description / Changes</th>
88
</tr>
99
</thead><tbody>
10+
11+
<tr valign=top>
12+
<td>1.5.1</td>
13+
<td>2017-11-16</td>
14+
<td>
15+
<li><a href="https://github.com/github/octocatalog-diff/pull/159">#159</a>: (Enhancement) Add support for puppetdb behind basic auth</li>
16+
</td>
17+
</tr>
18+
1019
<tr valign=top>
1120
<td>1.5.0</td>
1221
<td>2017-10-18</td>

doc/configuration-puppetdb.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ octocatalog-diff can interact with PuppetDB in the following ways:
88

99
For this to work, you will need to configure or provide information about your PuppetDB server to octocatalog-diff. You can provide this information via a [configuration file](/doc/configuration.md), via environment variables, or via command line parameters.
1010

11-
## Required information
11+
# Required information
1212

1313
- **Version of PuppetDB**: octocatalog-diff supports PuppetDB's query API v4, which requires that you be running PuppetDB 2.3 or higher.
1414

1515
- **URL to PuppetDB**: This is the URL with the host name and port number to reach your PuppetDB instance. If you have already set up your Puppet master to communicate with PuppetDB, you can see the URL by reviewing `/etc/puppetlabs/puppet/puppetdb.conf` (on Puppet Server) or `/etc/puppet/puppetdb.conf` (on Puppet Master 3.x). The URL (or URLs) to your PuppetDB installation are visible in the `server_urls` configuration setting.
1616

17-
- **SSL Authentication Information**: Whether your PuppetDB instance requires clients to authenticate via SSL certificates. Unless you have made a special effort to configure your PuppetDB instance not to require client certificates, it is likely that client certificate authentication is required.
17+
To use basic authentication, place the username and password in the URL, e.g.:
18+
19+
```
20+
https://username:[email protected]:8081
21+
```
22+
23+
- **SSL Authentication Information**: Whether your PuppetDB instance requires clients to authenticate via SSL certificates. Unless you have made a special effort to configure your PuppetDB instance not to require client certificates, it is likely that client certificate authentication is required. Please see the separate section below concerning SSL certificates.
1824

1925
NOTE: In certain situations, you may need to define or alter the `certificate-whitelist` setting in your PuppetDB configuration to whitelist the certificate used by octocatalog-diff. Please see [Configuring PuppetDB](https://docs.puppet.com/puppetdb/latest/configure.html#certificate-whitelist) in the Puppet documentation for additional information.
2026

@@ -25,9 +31,9 @@ The following settings can be used in a [configuration file](/doc/configuration.
2531
| Setting | Description |
2632
| --- | --- |
2733
| `settings[:puppetdb_url]` | PuppetDB URL settings. If this is a string, it will set a single PuppetDB URL. If it is an array, it will set multiple URLs, which will be tried in a random order until one responds. |
28-
| `settings[:puppetdb_ssl_ca]` | Path to the certificate of the CA that signed PuppetDB's certificate. This file is typically found in `/etc/puppetlabs/puppetdb/ssl/ca.pem` on your PuppetDB server. This file should contain only the public certificate, so it is safe to distribute to developer workstations or CI environments. |
29-
| `settings[:puppetdb_ssl_client_cert]` | TEXT of the certificate of the client SSL keypair. You should generate a keypair specifically for this client (or if you are running this on a machine managed by Puppet, you may be able to use the keypair for the client machine). You should **NOT** copy the certificate from your PuppetDB server itself. Note: This variable needs to be set to the TEXT of the certificate, and not the file path. This means you will likely want to use `File.read(...)` if you are configuring this to be read from a file. |
30-
| `settings[:puppetdb_ssl_client_key]` | TEXT of the private key of the client SSL keypair. You should generate a keypair specifically for this client (or if you are running this on a machine managed by Puppet, you may be able to use the keypair for the client machine). You should **NOT** copy the private key from your PuppetDB server itself. Note: This variable needs to be set to the TEXT of the key, and not the file path. This means you will likely want to use `File.read(...)` if you are configuring this to be read from a file. |
34+
| `settings[:puppetdb_ssl_ca]` | Path to the certificate of the CA that signed PuppetDB's certificate. This file should contain only the public certificate, so it is safe to distribute to developer workstations or CI environments. |
35+
| `settings[:puppetdb_ssl_client_cert]` | TEXT of the certificate of the client SSL keypair used to authenticate to PuppetDB. Note: This variable is not set to a file path, which means you will likely want to use `File.read(...)` if you are configuring this to be read from a file. |
36+
| `settings[:puppetdb_ssl_client_key]` | TEXT of the private key of the client SSL keypair used to authenticate to PuppetDB. Note: This variable is not set to a file path, which means you will likely want to use means you will likely want to use `File.read(...)` if you are configuring this to be read from a file. |
3137
| `settings[:puppetdb_ssl_client_pem]` | Concatenation of the text of `puppetdb_ssl_client_key` and `puppetdb_ssl_client_cert` as previously described. This is a good alternative if your certificate chain is complex and it's easier just to put everything in a single place. Note: this option is second in precedence; if `settings[:puppetdb_ssl_client_cert]` and `settings[:puppetdb_ssl_client_key]` are both set, this will be ignored. |
3238
| `settings[:puppetdb_ssl_client_password]` | Plain text string containing the password to unlock the private key. For keys generated by the Puppet Master CA, this is not required and should be left undefined. |
3339

@@ -38,9 +44,9 @@ The following arguments can be used on the command line.
3844
| Setting | Description |
3945
| --- | --- |
4046
| --puppetdb-url https://puppetdb.example.net:8081 | PuppetDB URL. The argument should match the `server_urls` configuration setting as described previously. Please note that only one URL is supported via the command line method, so if you have multiple `server_urls` URLs specified, you can only choose one. To use multiple URLs for failover purposes, please configure via configuration files. |
41-
| --puppetdb-ssl-ca FILENAME | Path to the certificate of the CA that signed PuppetDB's certificate. This file is typically found in `/etc/puppetlabs/puppetdb/ssl/ca.pem` on your PuppetDB server. This file should contain only the public certificate, so it is safe to distribute to developer workstations or CI environments. |
42-
| --puppetdb-ssl-client-cert FILENAME | Path to the certificate of the client SSL keypair. You should generate a keypair specifically for this client (or if you are running this on a machine managed by Puppet, you may be able to use the keypair for the client machine). You should **NOT** copy the certificate from your PuppetDB server itself. |
43-
| --puppetdb-ssl-client-key FILENAME | Path to the private key of the client SSL keypair. You should generate a keypair specifically for this client (or if you are running this on a machine managed by Puppet, you may be able to use the keypair for the client machine). You should **NOT** copy the private key from your PuppetDB server itself. |
47+
| --puppetdb-ssl-ca FILENAME | Path to the certificate of the CA that signed PuppetDB's certificate. This file should contain only the public certificate, so it is safe to distribute to developer workstations or CI environments. |
48+
| --puppetdb-ssl-client-cert FILENAME | Path to the certificate of the client SSL keypair. |
49+
| --puppetdb-ssl-client-key FILENAME | Path to the private key of the client SSL keypair. |
4450
| --puppetdb-ssl-client-password PASSWORD_STRING | Plain text string containing the password to unlock the private key. For keys generated by the Puppet Master CA, this is not required. |
4551

4652
## Supplying necessary information via the environment
@@ -50,3 +56,11 @@ The following arguments can be used on the command line.
5056
Set the environment variable `PUPPETDB_URL` to match the `server_urls` configuration setting as described previously. Please note that only one URL is supported via the environment variable method, so if you have multiple `server_urls` URLs specified, you can only choose one. To use multiple URLs for failover purposes, please configure via configuration files.
5157

5258
Environment variable support is not currently available for SSL client authentication settings.
59+
60+
# Notes about SSL certificates
61+
62+
SSL support is enabled via any of the `--puppetdb-ssl-...` command line options or `puppetdb_ssl_...` configuration settings as described above. Please note the following concerning these SSL certificates.
63+
64+
- The CA certificate should be the public certificate of the CA that signed your PuppetDB server's certificate. This file can be found in `/etc/puppetlabs/puppetdb/ssl/ca.pem` on a PuppetDB server. Since this is a public certificate, it is safe (and recommended) to distribute this file to any clients that may connect to this PuppetDB instance.
65+
66+
- The client keypair (key, certificate, and optionally password) should be generated individually for each client. You should NOT copy SSL keypairs from your PuppetDB server (or anywhere else) to your clients. If you are using `octocatalog-diff` on a system that is managed by Puppet, you may wish to use the same SSL credentials that the system uses to authenticate to Puppet. With recent versions of the Puppet agent, those certificates are found in `/etc/puppetlabs/puppet/ssl`.

rake/common.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# Constants
22
BASEDIR = File.expand_path('..', File.dirname(__FILE__)).freeze
33
PUPPET_BINARY = File.join(BASEDIR, 'bin', 'puppet').freeze
4-
TEST_COMMAND = "parallel_rspec --suffix '_spec.rb$'".freeze
4+
TEST_COMMAND = begin
5+
if ENV['TRAVIS']
6+
"rspec --pattern '*_spec.rb'"
7+
else
8+
"parallel_rspec --suffix '_spec.rb$'"
9+
end
10+
end.freeze

rake/spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def write_config(filename)
4646
end
4747
end
4848
write_config(logfile)
49-
abort unless system("bundle exec #{TEST_COMMAND} --runtime-log .parallel_runtime_rspec.log #{paths} 2>/dev/null")
49+
runtime_log = TEST_COMMAND =~ /parallel/ ? '--runtime-log .parallel_runtime_rspec.log' : ''
50+
cmd = "bundle exec #{TEST_COMMAND} #{runtime_log} #{paths} 2>/dev/null"
51+
abort unless system(cmd)
5052
f1 = File.open(File.expand_path('../.parallel_runtime_integration.log', File.dirname(__FILE__)), 'w')
5153
f2 = File.open(File.expand_path('../.parallel_runtime_tests.log', File.dirname(__FILE__)), 'w')
5254
File.read(logfile).split(/\n/).each do |line|
@@ -68,7 +70,8 @@ def write_config(filename)
6870
abort('Puppet binary missing. Please run script/bootstrap!') unless File.file?(PUPPET_BINARY)
6971
begin
7072
write_config('.parallel_runtime_integration.log')
71-
cmd = "bundle exec #{TEST_COMMAND} --runtime-log .parallel_runtime_integration.log spec/octocatalog-diff/integration"
73+
runtime_log = TEST_COMMAND =~ /parallel/ ? '--runtime-log .parallel_runtime_integration.log' : ''
74+
cmd = "bundle exec #{TEST_COMMAND} #{runtime_log} spec/octocatalog-diff/integration 2>/dev/null"
7275
abort unless system(cmd)
7376
ensure
7477
FileUtils.rm PARALLEL_CONFIG if File.file?(PARALLEL_CONFIG)
@@ -79,7 +82,8 @@ def write_config(filename)
7982
abort('Puppet binary missing. Please run script/bootstrap!') unless File.file?(PUPPET_BINARY)
8083
begin
8184
write_config('.parallel_runtime_tests.log')
82-
cmd = "bundle exec #{TEST_COMMAND} --runtime-log .parallel_runtime_tests.log spec/octocatalog-diff/tests"
85+
runtime_log = TEST_COMMAND =~ /parallel/ ? '--runtime-log .parallel_runtime_tests.log' : ''
86+
cmd = "bundle exec #{TEST_COMMAND} #{runtime_log} spec/octocatalog-diff/tests 2>/dev/null"
8387
abort unless system(cmd)
8488
ensure
8589
FileUtils.rm PARALLEL_CONFIG if File.file?(PARALLEL_CONFIG)

spec/octocatalog-diff/integration/examples_spec.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@
4040

4141
context 'executing' do
4242
before(:all) do
43-
@stdout, @stderr, @exitcode = Open3.capture3(@script)
43+
# Add retries just in case something goes wrong in CI
44+
3.times do
45+
@stdout, @stderr, @exitcode = Open3.capture3(@script)
46+
break if @exitcode.exitstatus.zero?
47+
end
4448
end
4549

4650
it 'should run without error' do
@@ -74,7 +78,11 @@
7478

7579
context 'executing' do
7680
before(:all) do
77-
@stdout, @stderr, @exitcode = Open3.capture3(@script)
81+
# Add retries just in case something goes wrong in CI
82+
3.times do
83+
@stdout, @stderr, @exitcode = Open3.capture3(@script)
84+
break if @exitcode.exitstatus.zero?
85+
end
7886
end
7987

8088
it 'should run without error' do
@@ -106,7 +114,11 @@
106114

107115
context 'executing' do
108116
before(:all) do
109-
@stdout, @stderr, @exitcode = Open3.capture3(@script)
117+
# Add retries just in case something goes wrong in CI
118+
3.times do
119+
@stdout, @stderr, @exitcode = Open3.capture3(@script)
120+
break if @exitcode.exitstatus.zero?
121+
end
110122
end
111123

112124
it 'should run without error' do

0 commit comments

Comments
 (0)