Sure. Here is the init.pp from the module (the only other manifest file is
the solaris_kernel_parameter.pp I pasted earlier.
$::is_prod is a top-level boolean variable we have to indicate a node is
production.
The module sets solaris kernel parameters from a hash passed to it. It also
handles zfs:zfs_arc_max separately, setting that value to be some fraction
of total memory.
manifests/init.pp:
class etc_system (
Integer $zfs_fraction = 0,
Boolean $manage_zfs_arc_cache = true,
Hash $kernel_settings = lookup('etc_system::kernel_settings', {
'value_type' => Hash, 'merge' => 'hash', 'default_value' => {} })
) {
# We only run this on Solaris...
if $facts['os']['family'] == 'Solaris' {
if $zfs_fraction <= 0 {
if $::is_prod {
$_zfs_fraction = 3
}
else {
$_zfs_fraction = 10
}
}
else {
$_zfs_fraction = $zfs_fraction
}
create_resources('etc_system::solaris_kernel_parameter',
$kernel_settings)
# Below we calculate the zfs cache size using the memorysizeinbytes
fact.
# If this fact isn't present, then the zfs cache size is not set.
if $facts['memorysizeinbytes'] and $manage_zfs_arc_cache {
$zfscache = $facts['memorysizeinbytes'] / $_zfs_fraction
etc_system::solaris_kernel_parameter { 'zfs_arc_max':
module => 'zfs',
value => inline_template('0x<%= @zfscache.to_s(16) %>')
}
}
}
else {
fail("The etc_system module is only intended to run on Solaris hosts.")
}
}
spec/spec_helper.rb:
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet'
require 'rspec-puppet-augeas'
# require 'rspec-puppet-facts'
# include RspecPuppetFacts
default_facts = {
puppetversion: Puppet.version,
facterversion: Facter.version,
}
default_facts_path = File.expand_path(File.join(File.dirname(__FILE__),
'default_facts.yml'))
default_module_facts_path = File.expand_path(File.join(File.dirname(__FILE__
), 'default_module_facts.yml'))
if File.exist?(default_facts_path) && File.readable?(default_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_facts_path)))
end
if File.exist?(default_module_facts_path) && File.readable?(
default_module_facts_path)
default_facts.merge!(YAML.safe_load(File.read(default_module_facts_path)))
end
RSpec.configure do |c|
c.default_facts = default_facts
c.module_path = File.join(File.dirname(File.expand_path(__FILE__)),
'fixtures', 'modules')
c.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)),
'fixtures', 'manifests')
c.augeas_fixtures = File.join(File.dirname(File.expand_path(__FILE__)),
'fixtures', 'augeas')
end
I commented out the rspec-puppet-facts stuff in my spec file because that
module does not support Solaris 10.
The spec/default_facts.yml file is the default PDK puts down:
# Use default_module_facts.yml for module specific facts.
#
# Facts specified here will override the values provided by
rspec-puppet-facts.
---
concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
is_prod: false
macaddress: "AA:AA:AA:AA:AA:AA"
Here is my custom spec/default_module_facts.yml:
---
architecture: "i86pc"
hardwaremodels:
- "i86pc"
kernel: "SunOS"
kernelmajversion: "Generic_142901-14"
kernelversion: "Generic_142901-14"
operatingsystem: "Solaris"
operatingsystemmajrelease: "10"
os:
architecture: "i86pc"
family: "Solaris"
hardware: "i86pc"
name: "Solaris"
release:
full: "10_u8"
major: "10"
minor: "8"
osfamily: "Solaris"
Thanks
Bill
On Monday, February 26, 2018 at 5:59:23 AM UTC-5, David Schmitt wrote:
>
> Hi Bill,
>
> from the code snippets you posted, nothing should be trying to initialize
> SSL (and thus causing this issue). Can you post the entire module somewhere
> for inspection? specifically your spec_helper.rb would be of interest. If
> you can't post it publicly, you can send a copy to [email protected]
> <javascript:>, a private alias.
>
> I've tried adding your code to an example module (
> https://github.com/DavidS/tmp-aug) but didn't get it to work in short
> order.
>
>
>
> Cheers, David
>
> On Tue, Feb 20, 2018 at 6:05 PM Bill Sirinek <[email protected]
> <javascript:>> wrote:
>
>>
>> I am continuing to work on unit tests for modules using PDK, and am
>> having issues with the augeas resources.
>> I added rspec-puppet-augeas to my Gemfile.local and pdk installed it, so
>> that part is fine.
>>
>> However, when I run the unit tests, the augeas resource fails. I tried
>> this on both my laptop running OSX 10.12.6, and on a RHEL 7.3 host, both
>> with the same PDK version (1.3.2) and rspec-puppet-augeas gem (0.4.0)
>>
>> I am doing these tests as myself, and not as root. I get errors because
>> something is trying to chown a file's owner to 0. My resource isn't
>> managing the owner/group/permissions of the file.
>>
>> *RHEL output:*
>>
>> bsirinek@rhelhost $ pdk test unit
>> [✔] Preparing to run the unit tests.
>> [✖] Running unit tests.
>> Evaluated 12 tests in 1.396288548 seconds: 1 failures, 0 pending.
>> [✔] Cleaning up after running unit tests.
>> failed: rspec: ./spec/defines/etc_system_solaris_kernel_parameter_spec.rb
>> :24: Got 2 failure(s) while initializing: File[/tmp/d20180220-14426-
>> bbcvri]: change from 'absent' to 'directory' failed: Failed to set owner
>> to '0': Operation not permitted @ chown_internal - /tmp/d20180220-14426-
>> bbcvri; File[/tmp/d20180220-14426-129ojbn/ssl]: change from 'absent' to
>> 'directory' failed: Failed to set owner to '0': Operation not permitted @
>> chown_internal - /tmp/d20180220-14426-129ojbn/ssl
>> etc_system::solaris_kernel_parameter Augeas[ip_squeue_enter] should run
>> Failure/Error:
>> }
>> }
>> it "should run" do
>> is_expected.to compile
>> is_expected.to contain_etc_system__solaris_kernel_parameter(
>> 'ip_squeue_enter').with('variable' => 'ip_squeue_enter', 'value' => '4',
>> 'operator' => '=', 'module' => 'ip')
>>
>>
>>
>>
>> *OSX output:*
>>
>> macbook:etc_system bsirinek$ pdk test unit
>> [✔] Preparing to run the unit tests.
>> [✖] Running unit tests.
>> Evaluated 12 tests in 2.153173 seconds: 1 failures, 0 pending.
>> [✔] Cleaning up after running unit tests.
>> failed: rspec: ./spec/defines/etc_system_solaris_kernel_parameter_spec.rb
>> :24: Got 2 failure(s) while initializing: File[/var/folders/vh/
>> 58bqgt717s1_xvljwqs5cz8jf0n1fx/T/d20180220-31763-cbt2p1]: change from
>> 'absent' to 'directory' failed: Failed to set owner to '0': Operation not
>> permitted @ chown_internal - /var/folders/vh/58bqgt717s1
>> _xvljwqs5cz8jf0n1fx/T/d20180220-31763-cbt2p1; File[/var/folders/vh/
>> 58bqgt717s1_xvljwqs5cz8jf0n1fx/T/d20180220-31763-gjico7/ssl]: change from
>> 'absent' to 'directory' failed: Failed to set owner to '0': Operation not
>> permitted @ chown_internal - /var/folders/vh/58bqgt717s1
>> _xvljwqs5cz8jf0n1fx/T/d20180220-31763-gjico7/ssl
>> etc_system::solaris_kernel_parameter Augeas[ip_squeue_enter] should run
>> Failure/Error:
>> }
>> }
>> it "should run" do
>> is_expected.to compile
>>
>>
>>
>>
>>
>> *Resource:*
>>
>> define etc_system::solaris_kernel_parameter(
>> $variable = $title,
>> $module = false,
>> $operator = '=',
>> $value = 0
>> ) {
>>
>>
>> augeas { $variable:
>> incl => '/etc/system',
>> lens => 'Solaris_System.lns',
>> changes => [
>> "rm set[./variable='${variable}']",
>> "set set[./variable='${variable}']/variable \'${variable}\'",
>> "ins module before set[./variable='${variable}']/variable",
>> "set set[./variable='${variable}']/module \'${module}\'",
>> "set set[./variable='${variable}']/operator \'${operator}\'",
>> "set set[./variable='${variable}']/value \'${value}\'"
>> ],
>> onlyif => "get set[./variable='${variable}']/value != \"${value}\"",
>> }
>> }
>>
>>
>> *spec/defines/etc_system_solaris_kernel_parameter_spec.rb:*
>>
>> require 'spec_helper'
>>
>>
>> describe "etc_system::solaris_kernel_parameter" do
>> let(:title) { 'ip_squeue_enter' }
>> let(:params) {
>> {
>> :value => '4',
>> :module => 'ip'
>> }
>> }
>> it "has an augeas resource" do
>> should contain_augeas("ip_squeue_enter")
>> end
>>
>>
>> describe_augeas "ip_squeue_enter", :lens => 'Solaris_System', :target
>> => 'etc/system' do
>> let(:title) { 'ip_squeue_enter' }
>>
>>
>> let(:params) {
>> {
>> :value => '4',
>> :module => 'ip'
>> }
>> }
>> it "should run" do
>> is_expected.to compile
>> is_expected.to contain_etc_system__solaris_kernel_parameter(
>> 'ip_squeue_enter').with('variable' => 'ip_squeue_enter', 'value' => '4',
>> 'operator' => '=', 'module' => 'ip')
>> should execute.with_change
>> aug_get("set[./variable='ip_squeue_enter']/value").should == "4"
>> should execute.idempotently
>> end
>> end
>> end
>>
>>
>>
>> Any help is greatly appreciated!
>>
>> Thanks
>>
>> Bill
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/ae8bfe8a-3df4-462d-a1c6-2e5809c39911%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/puppet-users/ae8bfe8a-3df4-462d-a1c6-2e5809c39911%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Cheers, David
>
> https://twitter.com/dev_el_ops
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/33ed4c1a-f686-4336-a20a-65d04fd58e32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.