Class: OctocatalogDiff::Catalog::PuppetMaster

Inherits:
OctocatalogDiff::Catalog show all
Defined in:
lib/octocatalog-diff/catalog/puppetmaster.rb

Overview

Represents a Puppet catalog that is obtained by contacting the Puppet Master.

Constant Summary collapse

DEFAULT_PUPPET_PORT_NUMBER =

Defaults

8140
DEFAULT_PUPPET_SERVER_API =
3
PUPPET_MASTER_TIMEOUT =
60

Instance Attribute Summary

Attributes inherited from OctocatalogDiff::Catalog

#built, #catalog, #catalog_json, #node, #options

Instance Method Summary collapse

Methods inherited from OctocatalogDiff::Catalog

#build, #builder, #compilation_dir, #compilation_dir=, #convert_file_resources, create, #environment, #error_message, #error_message=, #puppet_version, #resource, #resources, #retries, #valid?, #validate_references

Constructor Details

#initialize(options) ⇒ PuppetMaster

Constructor

Parameters:

  • :node (String)

    Node name

  • :retry_failed_catalog (Integer)

    Number of retries, if fetch fails

  • :branch (String)

    Environment to fetch from Puppet Master

  • :puppet_master (String)

    Puppet server and port number (assumed to be DEFAULT_PUPPET_PORT_NUMBER if not given)

  • :puppet_master_api_version (Integer)

    Puppet server API (default DEFAULT_PUPPET_SERVER_API)

  • :puppet_master_ssl_ca (String)

    Path to file used to sign puppet master's certificate

  • :puppet_master_ssl_verify (Boolean)

    Override the CA verification setting guessed from parameters

  • :puppet_master_ssl_client_pem (String)

    PEM-encoded client key and certificate

  • :puppet_master_ssl_client_p12 (String)

    pkcs12-encoded client key and certificate

  • :puppet_master_ssl_client_password (String)

    Path to file containing password for SSL client key (any format)

  • :puppet_master_ssl_client_auth (Boolean)

    Override the client-auth that is guessed from parameters

  • :timeout (Integer)

    Connection timeout for Puppet master (default=PUPPET_MASTER_TIMEOUT seconds)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/octocatalog-diff/catalog/puppetmaster.rb', line 34

def initialize(options)
  super

  unless @options[:node].is_a?(String) && @options[:node] != ''
    raise ArgumentError, 'node must be a non-empty string'
  end

  unless @options[:branch].is_a?(String) && @options[:branch] != ''
    raise ArgumentError, 'Environment must be a non-empty string'
  end

  unless @options[:puppet_master].is_a?(String) && @options[:puppet_master] != ''
    raise ArgumentError, 'Puppet Master must be a non-empty string'
  end

  @timeout = options.fetch(:puppet_master_timeout, options.fetch(:timeout, PUPPET_MASTER_TIMEOUT))
  @retry_failed_catalog = options.fetch(:retry_failed_catalog, 0)
  @options[:puppet_master] += ":#{DEFAULT_PUPPET_PORT_NUMBER}" unless @options[:puppet_master] =~ /\:\d+$/
end