Skip to content

Commit

Permalink
Fiddling with the specs to accomodate more than Red Hat
Browse files Browse the repository at this point in the history
  • Loading branch information
towo committed Dec 22, 2021
1 parent ad6effb commit ca25910
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 158 deletions.
33 changes: 20 additions & 13 deletions lib/puppet/provider/cs_primitive/crm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@
# for creating a new provider instance.
def self.element_to_hash(e)
hash = {
primitive_class: e.attributes['class'],
primitive_type: e.attributes['type'],
provided_by: e.attributes['provider'],
name: e.attributes['id'].to_sym,
ensure: :present,
provider: name,
parameters: nvpairs_to_hash(e.elements['instance_attributes']),
operations: [],
utilization: nvpairs_to_hash(e.elements['utilization']),
metadata: nvpairs_to_hash(e.elements['meta_attributes']),
existing_metadata: nvpairs_to_hash(e.elements['meta_attributes']),
ms_metadata: {},
promotable: :false
primitive_class: e.attributes['class'],
primitive_type: e.attributes['type'],
provided_by: e.attributes['provider'],
name: e.attributes['id'].to_sym,
ensure: :present,
provider: name,
parameters: nvpairs_to_hash(e.elements['instance_attributes']),
operations: [],
utilization: nvpairs_to_hash(e.elements['utilization']),
metadata: nvpairs_to_hash(e.elements['meta_attributes']),
ms_metadata: {},
promotable: :false,
existing_resource: :true,
existing_primitive_class: e.attributes['class'],
existing_primitive_type: e.attributes['type'],
existing_promotable: :false,
existing_provided_by: e.attributes['provider'],
existing_metadata: nvpairs_to_hash(e.elements['meta_attributes']),
existing_ms_metadata: {},
existing_operations: []
}

operations = e.elements['operations']
Expand Down
111 changes: 63 additions & 48 deletions spec/classes/corosync_qdevice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,75 @@
}
end

context 'standard quorum node install' do
['pcs', 'corosync-qnetd'].each do |package|
it "does install #{package}" do
is_expected.to contain_package(package).with(
ensure: 'present'
)
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(os_specific_facts(facts))
end
end

it 'creates the cluster group' do
is_expected.to contain_group('haclient').that_requires('Package[pcs]')
end
provider_package = case facts[:default_provider]
when 'pcs'
'pcs'
else
'crmsh'
end

it 'sets the hacluster password' do
is_expected.to contain_user('hacluster').with(
ensure: 'present',
password: 'some-secret-hash',
gid: 'haclient'
)
end
context 'standard quorum node install' do
[provider_package, 'corosync-qnetd'].each do |package|
it "does install #{package}" do
is_expected.to contain_package(package).with(
ensure: 'present'
)
end
end

it 'configures the pcsd service' do
is_expected.to contain_service('pcsd').with(
ensure: 'running',
enable: 'true',
require: [
'Package[pcs]',
'Package[corosync-qnetd]'
]
)
end
it 'creates the cluster group' do
is_expected.to contain_group('haclient').that_requires("Package[#{provider_package}]")
end

it 'configures the net quorum device' do
is_expected.to contain_exec('pcs qdevice setup model net --enable --start').with(
path: '/sbin:/bin:/usr/sbin:/usr/bin',
onlyif: [
'test ! -f /etc/corosync/qnetd/nssdb/qnetd-cacert.crt'
],
require: 'Service[pcsd]'
)
end
it 'sets the hacluster password' do
is_expected.to contain_user('hacluster').with(
ensure: 'present',
password: 'some-secret-hash',
gid: 'haclient'
)
end

it 'configures the pcsd service' do
is_expected.to contain_service('pcsd').with(
ensure: 'running',
enable: 'true',
require: [
'Package[pcs]',
'Package[corosync-qnetd]'
]
)
end

it 'makes sure the net quorum device is started' do
is_expected.to contain_exec('pcs qdevice start net').with(
path: '/sbin:/bin:/usr/sbin:/usr/bin',
onlyif: [
'test -f /etc/corosync/qnetd/nssdb/qnetd-cacert.crt',
'test 0 -ne $(pcs qdevice status net >/dev/null 2>&1; echo $?)'
],
require: [
'Package[pcs]',
'Package[corosync-qnetd]'
]
)
it 'configures the net quorum device' do
is_expected.to contain_exec('pcs qdevice setup model net --enable --start').with(
path: '/sbin:/bin:/usr/sbin:/usr/bin',
onlyif: [
'test ! -f /etc/corosync/qnetd/nssdb/qnetd-cacert.crt'
],
require: 'Service[pcsd]'
)
end

it 'makes sure the net quorum device is started' do
is_expected.to contain_exec('pcs qdevice start net').with(
path: '/sbin:/bin:/usr/sbin:/usr/bin',
onlyif: [
'test -f /etc/corosync/qnetd/nssdb/qnetd-cacert.crt',
'test 0 -ne $(pcs qdevice status net >/dev/null 2>&1; echo $?)'
],
require: [
'Package[pcs]',
'Package[corosync-qnetd]'
]
)
end
end
end
end
end
Loading

0 comments on commit ca25910

Please sign in to comment.