Skip to content

Commit 88ea090

Browse files
committed
WIP
1 parent 2c838ac commit 88ea090

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

lib/puppet_x/certs/common.rb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ module Common
6060
end
6161

6262
autorequire(:ca) do
63-
if @parameters.has_key?(:ca)
64-
catalog.resource(@parameters[:ca].value.to_s).to_hash[:name]
65-
end
63+
[self[:ca].title]
6664
end
6765

6866
autorequire(:file) do
@@ -102,19 +100,16 @@ module Common
102100
end
103101
end
104102

105-
define_method(:autorequire_cert) do |type|
106-
if @parameters.has_key?(:key_pair)
107-
key_pair = catalog.resource(@parameters[:key_pair].value.to_s)
108-
key_pair.to_hash[:name] if key_pair && key_pair.type == type
109-
end
110-
end
111-
112103
autorequire(:cert) do
113-
autorequire_cert('Cert')
104+
req = []
105+
req << self[:key_pair].title if self[:key_pair].type == 'Cert'
106+
req
114107
end
115108

116109
autorequire(:ca) do
117-
autorequire_cert('Ca')
110+
req = []
111+
req << self[:key_pair].title if self[:key_pair].type == 'Ca'
112+
req
118113
end
119114

120115
# Autorequire the nearest ancestor directory found in the catalog.

manifests/ca.pp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,21 @@
7171
}
7272

7373
if $deploy {
74-
Ca[$default_ca_name] ~>
7574
pubkey { $ca_cert:
7675
key_pair => $default_ca,
7776
} ~>
78-
pubkey { $ca_cert_stripped:
79-
strip => true,
80-
key_pair => $default_ca,
81-
} ~>
8277
file { $ca_cert:
8378
ensure => file,
8479
owner => 'root',
8580
group => $group,
8681
mode => '0644',
8782
}
8883

89-
Ca[$server_ca_name] ~>
84+
pubkey { $ca_cert_stripped:
85+
strip => true,
86+
key_pair => $default_ca,
87+
}
88+
9089
pubkey { $katello_server_ca_cert:
9190
key_pair => $server_ca,
9291
} ~>
@@ -98,7 +97,6 @@
9897
}
9998

10099
if $generate {
101-
Ca[$default_ca_name] ~>
102100
privkey { $ca_key:
103101
key_pair => $default_ca,
104102
unprotect => true,

spec/classes/certs_spec.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,27 @@
4040
.that_requires('File[/etc/pki/katello/private/katello-default-ca.pwd]')
4141
end
4242

43-
it { is_expected.to contain_privkey('/etc/pki/katello/private/katello-default-ca.key').that_requires('Ca[katello-default-ca]') }
43+
it do
44+
is_expected.to contain_privkey('/etc/pki/katello/private/katello-default-ca.key')
45+
.that_requires(['Ca[katello-default-ca]', 'File[/etc/pki/katello/private/katello-default-ca.pwd]'])
46+
end
47+
4448
it do
4549
is_expected.to contain_file('/etc/pki/katello/private/katello-default-ca.key')
46-
.that_subscribes_to(['Ca[katello-default-ca]', 'Privkey[/etc/pki/katello/private/katello-default-ca.key]'])
50+
.that_requires('Ca[katello-default-ca]')
51+
.that_subscribes_to('Privkey[/etc/pki/katello/private/katello-default-ca.key]')
4752
end
4853

49-
it { is_expected.to contain_pubkey('/etc/pki/katello/certs/katello-default-ca-stripped.crt').that_subscribes_to('Ca[katello-default-ca]') }
54+
it do
55+
is_expected.to contain_pubkey('/etc/pki/katello/certs/katello-default-ca-stripped.crt')
56+
.that_requires('Ca[katello-default-ca]')
57+
end
5058

5159
it { is_expected.to contain_pubkey('/etc/pki/katello/certs/katello-default-ca.crt').that_subscribes_to('Ca[katello-default-ca]') }
5260
it do
5361
is_expected.to contain_file('/etc/pki/katello/certs/katello-default-ca.crt')
54-
.that_subscribes_to(['Ca[katello-default-ca]', 'Pubkey[/etc/pki/katello/certs/katello-default-ca.crt]'])
62+
.that_requires('Ca[katello-default-ca]')
63+
.that_subscribes_to('Pubkey[/etc/pki/katello/certs/katello-default-ca.crt]')
5564
end
5665

5766
it do

0 commit comments

Comments
 (0)