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
43 44 45 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 43 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
37 38 39 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 37 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
53 54 55 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 53 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
28 29 30 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 28 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
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/beaker/dsl/helpers/hiera_helpers.rb', line 13 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 |