Skylar Thompson
03/06/2023, 11:09 PMpdk. I'd like to get in the habit of writing unit tests for our in-house modules, since we're going to be supporting more platforms than we've been needed in the past. Unfortunately, I haven't been able to get pdk test to work reliably on Ubuntu, though it seems to work fine on FreeBSD. I'm a FreeBSD person so not terribly upset, but most of my team mates will be using Ubuntu so could become a problem.
On FreeBSD, I just installed rubygem-pdk from Ports, made a test module w/ pdk new module and class w/ pdk new class, ran pdk test unit, and got feedback that the example tests all worked.
On Ubuntu, I did the same thing, and got
An error occurred while loading ./spec/classes/spectrum_protect_client_spec.rb.
Failure/Error: require 'puppetlabs_spec_helper/module_spec_helper'
TypeError:
no implicit conversion of nil into String
# /opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-4.0.1/lib/puppetlabs_spec_helper/module_spec_helper.rb:61:in `directory?'
# /opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-4.0.1/lib/puppetlabs_spec_helper/module_spec_helper.rb:61:in `block in <top (required)>'
# /opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-4.0.1/lib/puppetlabs_spec_helper/module_spec_helper.rb:60:in `each'
# /opt/puppetlabs/pdk/share/cache/ruby/2.7.0/gems/puppetlabs_spec_helper-4.0.1/lib/puppetlabs_spec_helper/module_spec_helper.rb:60:in `<top (required)>'
# ./spec/spec_helper.rb:7:in `require'
# ./spec/spec_helper.rb:7:in `<top (required)>'
# ./spec/classes/spectrum_protect_client_spec.rb:3:in `require'
# ./spec/classes/spectrum_protect_client_spec.rb:3:in `<top (required)>'
No examples found.
My gut instinct is that this might be a Ruby bug, but not sure. Has anyone run into this?rusty
03/06/2023, 11:19 PMGemfile.lock would also be useful. Did you run pdk bundle install before pdk test unit?rusty
03/06/2023, 11:30 PMrusty
03/06/2023, 11:34 PMspec/{defines,functions,hosts} otherwise mine is the same. They are empty dirs see if creating them changes anythingKen
03/07/2023, 12:09 AMKen
03/07/2023, 12:35 AMOlmo
03/07/2023, 11:52 AMr10k deploy environments for example ?Slackbot
03/07/2023, 12:04 PMDr Bunsen Honeydew
03/07/2023, 2:45 PMSlackbot
03/07/2023, 4:06 PMma_garvo
03/07/2023, 5:41 PMError: Could not install module 'binford2k-node_encrypt' (v2.0.0)
The requested version cannot satisfy one or more of the following installed modules:
puppetlabs-inifile, installed: 5.4.0, expected: >= 1.4.0 < 6.0.0Dr Bunsen Honeydew
03/07/2023, 5:41 PMbinford2k-node_encrypt module at https://forge.puppet.com/binford2k/node_encrypt?src=slack&channel=puppetSlackbot
03/07/2023, 6:37 PMKristian M
03/07/2023, 6:38 PMfile { "${install_dir}/wp-config.php":
staging_location => "/tmp",
require => Vcsrepo["${install_dir}"],
owner => $wp_config_owner,
group => $wp_config_group,
mode => $wp_config_mode,
content => epp(
'wordpress/wp-config.php.epp',
{
'domain' => $site_url,
'db_name' => $db_name,
'db_user' => $db_user,
'db_pass' => $db_password,
'db_host' => $db_host,
'db_table_prefix' => $db_table_prefix,
}
)
}
With the above the temporary file gets created in /tmp as root (puppet agent is running as root), so when it then tries to copy/move the temporary file to it’s final destination (${install_dir}/wp-config.php) it is failing, as root can not write to the NFS share.
How can I best work around this, besides changing any settings to the NFS share, which isn’t possible.
I would have expected even the temporary file to have been created as the specified owner/group, but that is clearly not the case.
Any advise or hints for possible workarounds are highly appreciated.
ThanksKristian M
03/07/2023, 6:39 PMSlackbot
03/07/2023, 6:41 PMSlackbot
03/07/2023, 6:41 PMSlackbot
03/07/2023, 7:49 PMDr Bunsen Honeydew
03/07/2023, 7:49 PMpuppetlabs-puppetdb module at https://forge.puppet.com/puppetlabs/puppetdb?src=slack&channel=puppetSlackbot
03/07/2023, 9:59 PMCorey Hickey
03/07/2023, 11:53 PMalias() function protects against this, but it would be nice to do, if feasible.
5. If the high-priority backend defers to lower priority backends via context.not_found, and the alias() function is not in use, then what is the concern with respect to:
If it was not found it must return a default value since if it signals “not found” hiera would continue the search and most likely return undef, resulting in an empty string."I would think that signaling "not found" is desirable whenever the high-priority backend does not find anything.
Corey Hickey
03/08/2023, 7:48 AMalias() always gets me in trouble.
Here's another way of looking at it: my general understanding of hiera is that higher levels of the hierarchy can only add to (or overwrite) data provided by the lower levels of the hierarchy; it's not usually possible to remove data specified lower in the hierarchy, at least without some kind of tricks. So, if an alias fails to find any value from the target key, then so be it: no value was found, so keep looking for the original key lower in the hierarchy.
I don't know how complete my understanding is, and maybe I'm rationalizing, but that seems consistent to me.Slackbot
03/08/2023, 12:02 PMbrokencode
03/08/2023, 12:02 PMstdlib::manage::create_resources: to create a file with eyaml encrypted content?
Something like:
stdlib::manage::create_resources:
file:
'/opt/foobar.conf':
ensure: file
mode: '0600'
owner: 'root'
group: 'root'
content: >
ENC[PKCS7,MIIB6wYJKoZIhvcNAQcDoIIB3DCCAdgCAQAxggEhMIIBHQIBAD
...
CmtBzSRToM9vWPR0Z1HqyrpcKHCgrUg2tVWI6OqFDod8SSis/j1/5TJWhIXL
tTj7bZfTTR]zipkid
03/08/2023, 12:54 PMbrokencode
03/08/2023, 1:05 PMstdlib::manage::create_resources: to create a file with eyaml encrypted content?
Something like:
``
`stdlib::manage::create_resources:`
`file:`
`'/opt/foobar.conf':`
`ensure: file`
`mode: '0600'`
`owner: 'root'`
`group: 'root'`
`content: >`
`ENC[PKCS7,MIIB6wYJKoZIhvcNAQcDoIIB3DCCAdgCAQAxggEhMIIBHQIBAD`
`...`
`CmtBzSRToM9vWPR0Z1HqyrpcKHCgrUg2tVWI6OqFDod8SSis/j1/5TJWhIXL`
`tTj7bZfTTR]`
``brokencode
03/08/2023, 1:05 PMstdlib::manage::create_resources: to create a file with eyaml encrypted content?
Something like:
stdlib::manage::create_resources:
file:
'/opt/foobar.conf':
ensure: file
mode: '0600'
owner: 'root'
group: 'root'
content: >
ENC[PKCS7,MIIB6wYJKoZIhvcNAQcDoIIB3DCCAdgCAQAxggEhMIIBHQIBAD
...
CmtBzSRToM9vWPR0Z1HqyrpcKHCgrUg2tVWI6OqFDod8SSis/j1/5TJWhIXL
tTj7bZfTTR]brokencode
03/08/2023, 1:06 PMstdlib::manage::create_resources: to create a file with eyaml encrypted content?
Something like:
stdlib::manage::create_resources:
file:
'/opt/foobar.conf':
ensure: file
mode: '0600'
owner: 'root'
group: 'root'
content: >
ENC[PKCS7,MIIB6wYJKoZIhvcNAQcDoIIB3DCCAdgCAQAxggEhMIIBHQIBAD
...
CmtBzSRToM9vWPR0Z1HqyrpcKHCgrUg2tVWI6OqFDod8SSis/j1/5TJWhIXL
tTj7bZfTTR]Slackbot
03/08/2023, 1:30 PMDavid Sandilands
03/08/2023, 2:21 PM