Module: Beaker::DSL::Helpers::HieraHelpers
- Included in:
- Beaker::DSL::Helpers
- Defined in:
- lib/beaker/dsl/helpers/hiera_helpers.rb
Overview
Methods that help you interact with your hiera installation, hiera must be installed for these methods to execute correctly
Instance Method Summary collapse
-
#copy_hiera_data(source) ⇒ Object
Copy hiera data files to the default host.
-
#copy_hiera_data_to(host, source) ⇒ Object
Copy hiera data files to one or more provided hosts.
-
#hiera_datadir(host) ⇒ String
Get file path to the hieradatadir for a given host.
-
#write_hiera_config(hierarchy) ⇒ Object
Write hiera config file for the default host.
-
#write_hiera_config_on(host, hierarchy) ⇒ Object
Write hiera config file on one or more provided hosts.
Instance Method Details
#copy_hiera_data(source) ⇒ Object
Copy hiera data files to the default host
54 55 56 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 54 def copy_hiera_data(source) copy_hiera_data_to(default, source) end |
#copy_hiera_data_to(host, source) ⇒ Object
Copy hiera data files to one or more provided hosts
@param[Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
or a role (String or Symbol) that identifies one or more hosts.
@param Directory containing the hiera data files.
48 49 50 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 48 def copy_hiera_data_to(host, source) scp_to host, File.(source), hiera_datadir(host) end |
#hiera_datadir(host) ⇒ String
Get file path to the hieradatadir for a given host. Handles whether or not a host is AIO-based & backwards compatibility
@param host Host you want to use the hieradatadir from
64 65 66 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 64 def hiera_datadir(host) host[:type] =~ /aio/ ? File.join(host.puppet['codedir'], 'hieradata') : host[:hieradatadir] end |
#write_hiera_config(hierarchy) ⇒ Object
Write hiera config file for the default host
39 40 41 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 39 def write_hiera_config(hierarchy) write_hiera_config_on(default, hierarchy) end |
#write_hiera_config_on(host, hierarchy) ⇒ Object
Write hiera config file on one or more provided hosts
@param[Host, Array<Host>, String, Symbol] host One or more hosts to act upon,
or a role (String or Symbol) that identifies one or more hosts.
@param One or more hierarchy paths
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 24 def write_hiera_config_on(host, hierarchy) block_on host do |host| hiera_config=Hash.new hiera_config[:backends] = 'yaml' hiera_config[:yaml] = {} hiera_config[:yaml][:datadir] = hiera_datadir(host) hiera_config[:hierarchy] = hierarchy hiera_config[:logger] = 'console' create_remote_file host, host.puppet['hiera_config'], hiera_config.to_yaml end end |