Skip to content

Commit 83fc87e

Browse files
authored
Merge pull request #10 from github/kpaulisse-puppetdb-termini
Remove dependency on puppetdb-terminus if storeconfigs is not used
2 parents 5b6131e + 5b18543 commit 83fc87e

8 files changed

Lines changed: 71 additions & 10 deletions

File tree

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.1
1+
0.5.3

doc/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# octocatalog-diff change log
2+
3+
| Version | Date | Description / Changes |
4+
| ------- | ---- | ----------- |
5+
| 0.5.3 | 2016-10-31 | https://github.com/github/octocatalog-diff/pull/10: facts terminus optimization |
6+
| 0.5.2 | - | Unreleased internal version |
7+
| 0.5.1 | 2016-10-20 | Initial release |

doc/configuration-puppet.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Configuring octocatalog-diff to use Puppet
2+
3+
The most common use of `octocatalog-diff` is to use `puppet` locally to compile catalogs.
4+
5+
In order to successfully use Puppet to compile catalogs:
6+
7+
0. Puppet must be installed on the system.
8+
9+
It is the goal of `octocatalog-diff` to support Puppet version 3.8 and higher, installed via any means supported by Puppet. This includes the [All-In-One agent package](https://docs.puppet.com/puppet/4.0/reference/release_notes.html#all-in-one-packaging) or installed as a Ruby gem.
10+
11+
By default, `octocatalog-diff` will look for the Puppet binary in several common system locations.
12+
13+
For maximum reliability, you can specify the full path to the Puppet binary in the configuration file. For example:
14+
15+
```
16+
##############################################################################################
17+
# puppet_binary
18+
# This is the full path to the puppet binary on your system. If you don't specify this,
19+
# the tool will just run 'puppet' and hope to find it in your path.
20+
##############################################################################################
21+
22+
# settings[:puppet_binary] = '/usr/bin/puppet'
23+
settings[:puppet_binary] = '/opt/puppetlabs/puppet/bin/puppet'
24+
```
25+
26+
0. Applies if you are using [exported resources](https://docs.puppet.com/puppet/latest/reference/lang_exported.html) from PuppetDB (i.e., the octocatalog-diff `--storeconfigs` option enabled):
27+
28+
Your Puppet installation must have the `puppetdb-termini` feature available. This feature may not be included by default with the Puppet agent package.
29+
30+
Consult the [Connecting Puppet masters to PuppetDB](https://docs.puppet.com/puppetdb/latest/connect_puppet_master.html#step-1-install-plug-ins) documentation for instructions on installing the `puppetdb-termini` gem.
31+
32+
:warning: Attention Mac OS users: the [documentation](https://docs.puppet.com/puppet/latest/reference/puppet_collections.html#os-x-systems) states:
33+
34+
> While the puppet-agent package is the only component of a Puppet Collection available on OS X, you can still use Puppet Collections to ensure the version of package-agent you install is compatible with the Puppet Collection powering your infrastructure.
35+
36+
Unfortunately this means that you won't be able to enable `--storeconfigs` with the All-In-One Puppet Agent on Mac OS X, unless you manually install a gem-packaged version of `puppetdb-terminus`. The procedure for this is beyond the scope of this documentation.

doc/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- [Configuring octocatalog-diff to use Hiera](/doc/configuration-hiera.md)
4040
- [Configuring octocatalog-diff to use ENC](/doc/configuration-enc.md)
4141
- [Configuring octocatalog-diff to use PuppetDB](/doc/configuration-puppetdb.md)
42+
- [Configuring octocatalog-diff to use Puppet](/doc/configuration-puppet.md)
4243
4344
0. Test the configuration, which will indicate the location of the configuration file and validate the contents thereof.
4445

examples/octocatalog-diff.cfg.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,19 @@ def self.config
158158
# the tool will just run 'puppet' and hope to find it in your path.
159159
##############################################################################################
160160

161+
# These are some common defaults. We recommend removing this and setting explicitly below.
162+
puppet_may_be_in = %w(
163+
bin/puppet
164+
/opt/puppetlabs/puppet/bin/puppet
165+
/usr/bin/puppet
166+
/usr/local/bin/puppet
167+
)
168+
puppet_may_be_in.each do |path|
169+
next unless File.executable?(path)
170+
settings[:puppet_binary] = path
171+
break
172+
end
173+
161174
# settings[:puppet_binary] = '/usr/bin/puppet'
162175
# settings[:puppet_binary] = '/opt/puppetlabs/puppet/bin/puppet'
163176

lib/octocatalog-diff/catalog-util/builddir.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def initialize(options = {}, logger = nil)
4242
@enc = nil
4343
@fact_file = nil
4444
@node = options[:node]
45+
@facts_terminus = options.fetch(:facts_terminus, 'yaml')
4546

4647
create_structure
4748
install_directory_symlink(logger, options[:basedir])
@@ -54,7 +55,7 @@ def initialize(options = {}, logger = nil)
5455
unless options[:hiera_config].nil?
5556
install_hiera_config(logger, options[:hiera_config], options[:hiera_path_strip])
5657
end
57-
@fact_file = install_fact_file(logger, options) unless options.fetch(:facts_terminus, 'yaml') != 'yaml'
58+
@fact_file = install_fact_file(logger, options) if @facts_terminus == 'yaml'
5859
@enc = install_enc(logger) unless options[:enc].nil? && options[:pe_enc_url].nil?
5960
install_ssl(logger, options) if options[:puppetdb_ssl_ca] || options[:puppetdb_ssl_client_cert]
6061
end
@@ -98,7 +99,7 @@ def install_routes_yaml(logger)
9899
routes_hash = {
99100
'master' => {
100101
'facts' => {
101-
'terminus' => 'puppetdb',
102+
'terminus' => @facts_terminus,
102103
'cache' => 'yaml'
103104
},
104105
'catalog' => {
@@ -113,8 +114,8 @@ def install_routes_yaml(logger)
113114
# Install the fact file in temporary directory
114115
# @param options [Hash] Options
115116
def install_fact_file(logger, options)
116-
unless options[:facts_terminus].nil? || options[:facts_terminus] == 'yaml'
117-
raise ArgumentError, "Called install_fact_file but :facts_terminus = #{options[:facts_terminus]}"
117+
unless @facts_terminus == 'yaml'
118+
raise ArgumentError, "Called install_fact_file but :facts_terminus = #{@facts_terminus}"
118119
end
119120
unless options[:node].is_a?(String) && !options[:node].empty?
120121
raise ArgumentError, 'Called install_fact_file without node, or with an empty node'

lib/octocatalog-diff/catalog/computed.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def initialize(options)
4444
@puppet_command = options[:puppet_command]
4545
@retries = nil
4646
@builddir = nil
47+
@facts_terminus = options.fetch(:facts_terminus, 'yaml')
4748

4849
# Pass through the input for other access
4950
@opts = options
@@ -52,10 +53,12 @@ def initialize(options)
5253

5354
# Actually build the catalog (populate @error_message, @catalog, @catalog_json)
5455
def build(logger = Logger.new(StringIO.new))
55-
facts_obj = OctocatalogDiff::CatalogUtil::Facts.new(@opts, logger)
56-
logger.debug "Start retrieving facts for #{@node} from #{self.class}"
57-
@opts[:facts] = facts_obj.facts
58-
logger.debug "Success retrieving facts for #{@node} from #{self.class}"
56+
if @facts_terminus != 'facter'
57+
facts_obj = OctocatalogDiff::CatalogUtil::Facts.new(@opts, logger)
58+
logger.debug "Start retrieving facts for #{@node} from #{self.class}"
59+
@opts[:facts] = facts_obj.facts
60+
logger.debug "Success retrieving facts for #{@node} from #{self.class}"
61+
end
5962
build_catalog(logger)
6063
end
6164

spec/octocatalog-diff/tests/catalog-util/builddir_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
expect(content.size).to eq(7)
117117
routes_yaml = YAML.load_file(File.join(testobj.tempdir, 'routes.yaml'))
118118
expect(routes_yaml).to eq('master' => {
119-
'facts' => { 'terminus' => 'puppetdb', 'cache' => 'yaml' },
119+
'facts' => { 'terminus' => 'facter', 'cache' => 'yaml' },
120120
'catalog' => { 'cache' => 'json' }
121121
})
122122
end

0 commit comments

Comments
 (0)