Skip to content

Commit 2b0a129

Browse files
authored
Merge pull request #8625 from ciprianbadescu/main
(maint) Merge 6.x to main
2 parents fc8dd47 + 0fe4c43 commit 2b0a129

File tree

13 files changed

+134
-38
lines changed

13 files changed

+134
-38
lines changed

acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
teardown do
2525
modify_tk_config(master, options['puppetserver-config'], {'jruby-puppet' => {'use-legacy-auth-conf' => true}})
2626
on master, 'cp /etc/puppetlabs/puppetserver/conf.d/auth.bak /etc/puppetlabs/puppetserver/conf.d/auth.conf'
27+
on master, "service #{master['puppetservice']} reload"
2728
end
2829

2930
step "Setup tk-auth rules" do

acceptance/tests/allow_arbitrary_node_name_for_agent.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
teardown do
1717
on master, 'cp /etc/puppetlabs/puppetserver/conf.d/auth.bak /etc/puppetlabs/puppetserver/conf.d/auth.conf'
1818
modify_tk_config(master, options['puppetserver-config'], {'jruby-puppet' => {'use-legacy-auth-conf' => true}})
19+
on master, "service #{master['puppetservice']} reload"
1920
end
2021

2122
step "Setup tk-auth rules" do

ext/osx/puppet.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@
2626
<string>/var/log/puppetlabs/puppet/puppet.log</string>
2727
<key>StandardOutPath</key>
2828
<string>/var/log/puppetlabs/puppet/puppet.log</string>
29+
<key>SessionCreate</key>
30+
<true />
2931
</dict>
3032
</plist>

lib/puppet/pops/types/p_sem_ver_type.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,22 @@ def from_string(str)
9595
end
9696

9797
def from_args(major, minor, patch, prerelease = nil, build = nil)
98-
SemanticPuppet::Version.new(major, minor, patch, prerelease, build)
98+
SemanticPuppet::Version.new(major, minor, patch, to_array(prerelease), to_array(build))
9999
end
100100

101101
def from_hash(hash)
102-
SemanticPuppet::Version.new(hash['major'], hash['minor'], hash['patch'], hash['prerelease'], hash['build'])
102+
SemanticPuppet::Version.new(hash['major'], hash['minor'], hash['patch'], to_array(hash['prerelease']), to_array(hash['build']))
103103
end
104104

105105
def on_error(str)
106106
_("The string '%{str}' cannot be converted to a SemVer") % { str: str }
107107
end
108+
109+
private
110+
111+
def to_array(component)
112+
component ? [component] : nil
113+
end
108114
end
109115
end
110116

lib/puppet/provider/package/nim.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,25 @@ def install(useversion = true)
154154
# I spent a lot of time trying to figure out a solution that didn't
155155
# require parsing the `nimclient -o showres` output and was unable to
156156
# do so.
157-
self::HEADER_LINE_REGEX = /^([^\s]+)\s+[^@]+@@(I|R):(\1)\s+[^\s]+$/
158-
self::PACKAGE_LINE_REGEX = /^.*@@(I|R):(.*)$/
159-
self::RPM_PACKAGE_REGEX = /^(.*)-(.*-\d+) \2$/
157+
self::HEADER_LINE_REGEX = /^([^\s]+)\s+[^@]+@@(I|R|S):(\1)\s+[^\s]+$/
158+
self::PACKAGE_LINE_REGEX = /^.*@@(I|R|S):(.*)$/
159+
self::RPM_PACKAGE_REGEX = /^(.*)-(.*-\d+\w*) \2$/
160160
self::INSTALLP_PACKAGE_REGEX = /^(.*) (.*)$/
161161

162162
# Here is some sample output that shows what the above regexes will be up
163163
# against:
164-
# FOR AN INSTALLP PACKAGE:
164+
# FOR AN INSTALLP(bff) PACKAGE:
165165
#
166166
# mypackage.foo ALL @@I:mypackage.foo _all_filesets
167-
# @ 1.2.3.1 MyPackage Runtime Environment @@I:mypackage.foo 1.2.3.1
168167
# + 1.2.3.4 MyPackage Runtime Environment @@I:mypackage.foo 1.2.3.4
169168
# + 1.2.3.8 MyPackage Runtime Environment @@I:mypackage.foo 1.2.3.8
170169
#
170+
# FOR AN INSTALLP(bff) PACKAGE with security update:
171+
#
172+
# bos.net ALL @@S:bos.net _all_filesets
173+
# + 7.2.0.1 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.1
174+
# + 7.2.0.2 TCP/IP ntp Applications @@S:bos.net.tcp.ntp 7.2.0.2
175+
#
171176
# FOR AN RPM PACKAGE:
172177
#
173178
# mypackage.foo ALL @@R:mypackage.foo _all_filesets
@@ -243,7 +248,7 @@ def parse_showres_package_line(line)
243248
package_string = match.captures[1]
244249

245250
case package_type_flag
246-
when "I"
251+
when "I","S"
247252
parse_installp_package_string(package_string)
248253
when "R"
249254
parse_rpm_package_string(package_string)

lib/puppet/provider/service/systemd.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,15 @@ def enable
164164
end
165165

166166
def mask
167-
self.disable
167+
disable if exist?
168168
systemctl_change_enable(:mask)
169169
end
170170

171+
def exist?
172+
result = execute([command(:systemctl), 'cat', '--', @resource[:name]], :failonfail => false)
173+
result.exitstatus == 0
174+
end
175+
171176
def unmask
172177
systemctl_change_enable(:unmask)
173178
end

lib/puppet/provider/user/directoryservice.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,7 @@ def set_shadow_hash_data(users_plist, binary_plist)
591591
else
592592
users_plist['ShadowHashData'] = [binary_plist]
593593
end
594-
if Puppet::Util::Package.versioncmp(self.class.get_os_version, '10.15') < 0
595-
write_users_plist_to_disk(users_plist)
596-
else
597-
write_and_import_shadow_hash_data(users_plist['ShadowHashData'].first)
598-
end
594+
write_and_import_shadow_hash_data(users_plist['ShadowHashData'].first)
599595
end
600596

601597
# This method writes the ShadowHashData plist in a temporary file,
@@ -671,12 +667,6 @@ def set_salted_pbkdf2(users_plist, shadow_hash_data, field, value)
671667
set_shadow_hash_data(users_plist, binary_plist)
672668
end
673669

674-
# This method will accept a plist in XML format, save it to disk, convert
675-
# the plist to a binary format, and flush the dscl cache.
676-
def write_users_plist_to_disk(users_plist)
677-
Puppet::Util::Plist.write_plist_file(users_plist, "#{users_plist_dir}/#{@resource.name}.plist", :binary)
678-
end
679-
680670
private
681671

682672
SHA512_PBKDF2_AUTHENTICATION_AUTHORITY = ';ShadowHash;HASHLIST:<SALTED-SHA512-PBKDF2,SRP-RFC5054-4096-SHA512-PBKDF2>'

lib/puppet/transaction/additional_resource_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def add_resource(res, parent_resource, priority=nil)
137137
else
138138
@catalog.add_resource_after(parent_resource, res)
139139
end
140-
@catalog.add_edge(@catalog.container_of(parent_resource), res)
140+
@catalog.add_edge(@catalog.container_of(parent_resource), res) if @catalog.container_of(parent_resource)
141141
if @relationship_graph && priority
142142
# If we have a relationship_graph we should add the resource
143143
# to it (this is an eval_generate). If we don't, then the
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'spec_helper'
2+
require 'puppet_spec/files'
3+
4+
describe "puppet resource", unless: Puppet::Util::Platform.jruby? do
5+
include PuppetSpec::Files
6+
7+
let(:resource) { Puppet::Application[:resource] }
8+
9+
describe "when handling file and tidy types" do
10+
let!(:dir) { dir_containing('testdir', 'testfile' => 'contents') }
11+
12+
it 'does not raise when generating file resources' do
13+
resource.command_line.args = ['file', dir, 'ensure=directory', 'recurse=true']
14+
15+
expect {
16+
resource.run
17+
}.to output(/ensure.+=> 'directory'/).to_stdout
18+
end
19+
20+
it 'correctly cleans up a given path' do
21+
resource.command_line.args = ['tidy', dir, 'rmdirs=true', 'recurse=true']
22+
23+
expect {
24+
resource.run
25+
}.to output(/Notice: \/File\[#{dir}\]\/ensure: removed/).to_stdout
26+
27+
expect(Puppet::FileSystem.exist?(dir)).to be false
28+
end
29+
end
30+
end

spec/unit/pops/types/p_sem_ver_type_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ module Types
125125
expect(eval_and_collect_notices(code)).to eql(['true', 'false'])
126126
end
127127

128+
it 'can be compared to another instance created from arguments' do
129+
code = <<-CODE
130+
$x = SemVer('1.2.3-rc4+5')
131+
$y = SemVer(1, 2, 3, 'rc4', '5')
132+
notice($x == $y)
133+
CODE
134+
expect(eval_and_collect_notices(code)).to eql(['true'])
135+
end
136+
137+
it 'can be compared to another instance created from a hash' do
138+
code = <<-CODE
139+
$x = SemVer('1.2.3-rc4+5')
140+
$y = SemVer(major => 1, minor => 2, patch => 3, prerelease => 'rc4', build => '5')
141+
notice($x == $y)
142+
CODE
143+
expect(eval_and_collect_notices(code)).to eql(['true'])
144+
end
145+
128146
it 'can be compared to another instance for magnitude' do
129147
code = <<-CODE
130148
$x = SemVer('1.1.1')

0 commit comments

Comments
 (0)