Module: Beaker::DSL::Helpers::Hiera
- Defined in:
- lib/beaker-hiera/helpers.rb,
lib/beaker-hiera/version.rb
Overview
Methods that help you interact with your hiera installation. Hiera must be installed for these methods to execute correctly.
Defined Under Namespace
Modules: Version
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
59 60 61 |
# File 'lib/beaker-hiera/helpers.rb', line 59 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
47 48 49 50 51 |
# File 'lib/beaker-hiera/helpers.rb', line 47 def copy_hiera_data_to(host, source) block_on host do |hst| scp_to hst, File.(source), hiera_datadir(hst) end 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
70 71 72 |
# File 'lib/beaker-hiera/helpers.rb', line 70 def hiera_datadir(host) File.join(host.puppet['codedir'], 'hieradata') end |
#write_hiera_config(hierarchy) ⇒ Object
Write hiera config file for the default host
36 37 38 |
# File 'lib/beaker-hiera/helpers.rb', line 36 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
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/beaker-hiera/helpers.rb', line 16 def write_hiera_config_on(host, hierarchy) block_on host do |hst| hiera_config = { 'version' => 5, 'defaults' => { 'datadir' => hiera_datadir(hst), 'data_hash' => 'yaml_data', }, 'hierarchy' => hierarchy, } create_remote_file hst, hst.puppet['hiera_config'], hiera_config.to_yaml end end |