bolt 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +5 -2
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb +5 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +5 -8
- data/lib/bolt/applicator.rb +11 -8
- data/lib/bolt/boltdir.rb +13 -5
- data/lib/bolt/catalog.rb +22 -47
- data/lib/bolt/config.rb +1 -26
- data/lib/bolt/executor.rb +1 -1
- data/lib/bolt/outputter.rb +0 -9
- data/lib/bolt/outputter/human.rb +29 -14
- data/lib/bolt/outputter/json.rb +12 -1
- data/lib/bolt/pal.rb +12 -10
- data/lib/bolt/target.rb +0 -6
- data/lib/bolt/task.rb +53 -10
- data/lib/bolt/transport/base.rb +1 -6
- data/lib/bolt/transport/local.rb +11 -13
- data/lib/bolt/transport/local/shell.rb +2 -2
- data/lib/bolt/transport/ssh.rb +16 -11
- data/lib/bolt/transport/winrm.rb +8 -11
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_ext/schemas/task.json +12 -5
- data/libexec/apply_catalog.rb +3 -1
- data/libexec/bolt_catalog +4 -0
- data/vendored/puppet/lib/puppet.rb +2 -1
- data/vendored/puppet/lib/puppet/application/agent.rb +2 -6
- data/vendored/puppet/lib/puppet/application/apply.rb +100 -60
- data/vendored/puppet/lib/puppet/application/cert.rb +26 -291
- data/vendored/puppet/lib/puppet/application/device.rb +0 -5
- data/vendored/puppet/lib/puppet/application/lookup.rb +1 -1
- data/vendored/puppet/lib/puppet/application/ssl.rb +133 -0
- data/vendored/puppet/lib/puppet/application_support.rb +1 -2
- data/vendored/puppet/lib/puppet/configurer.rb +34 -50
- data/vendored/puppet/lib/puppet/configurer/downloader.rb +1 -1
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -1
- data/vendored/puppet/lib/puppet/daemon.rb +1 -1
- data/vendored/puppet/lib/puppet/defaults.rb +40 -117
- data/vendored/puppet/lib/puppet/face/epp.rb +2 -2
- data/vendored/puppet/lib/puppet/face/help.rb +21 -7
- data/vendored/puppet/lib/puppet/face/node/clean.rb +14 -10
- data/vendored/puppet/lib/puppet/feature/base.rb +7 -23
- data/vendored/puppet/lib/puppet/feature/eventlog.rb +1 -1
- data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -2
- data/vendored/puppet/lib/puppet/file_serving/fileset.rb +1 -1
- data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -2
- data/vendored/puppet/lib/puppet/functions.rb +133 -0
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -5
- data/vendored/puppet/lib/puppet/functions/filter.rb +7 -6
- data/vendored/puppet/lib/puppet/functions/new.rb +37 -53
- data/vendored/puppet/lib/puppet/functions/warning.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -5
- data/vendored/puppet/lib/puppet/gettext/config.rb +1 -1
- data/vendored/puppet/lib/puppet/graph.rb +0 -2
- data/vendored/puppet/lib/puppet/indirector/catalog/json.rb +14 -3
- data/vendored/puppet/lib/puppet/indirector/catalog/yaml.rb +0 -16
- data/vendored/puppet/lib/puppet/indirector/certificate/file.rb +0 -1
- data/vendored/puppet/lib/puppet/indirector/facts/yaml.rb +4 -2
- data/vendored/puppet/lib/puppet/indirector/key/file.rb +1 -6
- data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -3
- data/vendored/puppet/lib/puppet/indirector/node/yaml.rb +0 -6
- data/vendored/puppet/lib/puppet/indirector/request.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +3 -44
- data/vendored/puppet/lib/puppet/indirector/yaml.rb +4 -4
- data/vendored/puppet/lib/puppet/info_service/task_information_service.rb +7 -3
- data/vendored/puppet/lib/puppet/loaders.rb +1 -0
- data/vendored/puppet/lib/puppet/module/task.rb +198 -29
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/vendored/puppet/lib/puppet/network/format_support.rb +13 -8
- data/vendored/puppet/lib/puppet/network/formats.rb +93 -2
- data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +10 -3
- data/vendored/puppet/lib/puppet/node/facts.rb +11 -1
- data/vendored/puppet/lib/puppet/parser/catalog_compiler.rb +56 -0
- data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -1
- data/vendored/puppet/lib/puppet/parser/functions.rb +3 -1
- data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/generate.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/sprintf.rb +12 -1
- data/vendored/puppet/lib/puppet/parser/functions/tagged.rb +1 -4
- data/vendored/puppet/lib/puppet/parser/scope.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/script_compiler.rb +7 -2
- data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +23 -4
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +3 -4
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +4 -0
- data/vendored/puppet/lib/puppet/pops/issues.rb +8 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +30 -9
- data/vendored/puppet/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +62 -0
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +13 -70
- data/vendored/puppet/lib/puppet/pops/loaders.rb +19 -29
- data/vendored/puppet/lib/puppet/pops/lookup/hiera_config.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +4 -1
- data/vendored/puppet/lib/puppet/pops/pcore.rb +10 -33
- data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -0
- data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -1
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +11 -3
- data/vendored/puppet/lib/puppet/pops/serialization/to_stringified_converter.rb +226 -0
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -0
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +97 -47
- data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +7 -8
- data/vendored/puppet/lib/puppet/property/keyvalue.rb +70 -8
- data/vendored/puppet/lib/puppet/provider/aix_object.rb +483 -0
- data/vendored/puppet/lib/puppet/provider/file/windows.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/group/aix.rb +51 -112
- data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/pip.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/puppet_gem.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/rpm.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/windows/package.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/package/zypper.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/service/windows.rb +37 -40
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +142 -254
- data/vendored/puppet/lib/puppet/resource.rb +20 -3
- data/vendored/puppet/lib/puppet/resource/catalog.rb +2 -12
- data/vendored/puppet/lib/puppet/rest/routes.rb +97 -34
- data/vendored/puppet/lib/puppet/settings.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/file_setting.rb +1 -1
- data/vendored/puppet/lib/puppet/ssl/base.rb +1 -9
- data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +1 -13
- data/vendored/puppet/lib/puppet/ssl/certificate_request_attributes.rb +1 -1
- data/vendored/puppet/lib/puppet/ssl/host.rb +114 -232
- data/vendored/puppet/lib/puppet/ssl/key.rb +1 -5
- data/vendored/puppet/lib/puppet/ssl/oids.rb +1 -1
- data/vendored/puppet/lib/puppet/test/test_helper.rb +0 -4
- data/vendored/puppet/lib/puppet/transaction/event.rb +3 -7
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
- data/vendored/puppet/lib/puppet/type/exec.rb +18 -16
- data/vendored/puppet/lib/puppet/type/file.rb +3 -3
- data/vendored/puppet/lib/puppet/type/file/source.rb +20 -7
- data/vendored/puppet/lib/puppet/type/group.rb +3 -5
- data/vendored/puppet/lib/puppet/type/notify.rb +1 -1
- data/vendored/puppet/lib/puppet/type/package.rb +2 -5
- data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
- data/vendored/puppet/lib/puppet/type/service.rb +3 -6
- data/vendored/puppet/lib/puppet/type/tidy.rb +1 -1
- data/vendored/puppet/lib/puppet/type/user.rb +13 -20
- data/vendored/puppet/lib/puppet/util.rb +8 -9
- data/vendored/puppet/lib/puppet/util/execution.rb +3 -3
- data/vendored/puppet/lib/puppet/util/feature.rb +61 -39
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +1 -1
- data/vendored/puppet/lib/puppet/util/rdoc.rb +1 -1
- data/vendored/puppet/lib/puppet/util/run_mode.rb +1 -1
- data/vendored/puppet/lib/puppet/util/storage.rb +1 -1
- data/vendored/puppet/lib/puppet/util/suidmanager.rb +7 -5
- data/vendored/puppet/lib/puppet/util/tag_set.rb +1 -1
- data/vendored/puppet/lib/puppet/util/tagging.rb +1 -1
- data/vendored/puppet/lib/puppet/util/windows.rb +18 -2
- data/vendored/puppet/lib/puppet/util/windows/adsi.rb +154 -205
- data/vendored/puppet/lib/puppet/util/windows/service.rb +770 -0
- data/vendored/puppet/lib/puppet/util/yaml.rb +41 -5
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +280 -24
- metadata +8 -38
- data/lib/bolt/catalog/compiler.rb +0 -48
- data/lib/bolt/catalog/loaders.rb +0 -19
- data/vendored/puppet/lib/puppet/application/ca.rb +0 -11
- data/vendored/puppet/lib/puppet/application/certificate.rb +0 -17
- data/vendored/puppet/lib/puppet/application/certificate_request.rb +0 -7
- data/vendored/puppet/lib/puppet/application/certificate_revocation_list.rb +0 -7
- data/vendored/puppet/lib/puppet/face/ca.rb +0 -266
- data/vendored/puppet/lib/puppet/face/certificate.rb +0 -167
- data/vendored/puppet/lib/puppet/face/certificate_request.rb +0 -56
- data/vendored/puppet/lib/puppet/face/certificate_revocation_list.rb +0 -56
- data/vendored/puppet/lib/puppet/graph/random_prioritizer.rb +0 -16
- data/vendored/puppet/lib/puppet/graph/title_hash_prioritizer.rb +0 -16
- data/vendored/puppet/lib/puppet/indirector/certificate/ca.rb +0 -9
- data/vendored/puppet/lib/puppet/indirector/certificate/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_request/ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_request/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/ca.rb +0 -8
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/file.rb +0 -8
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
- data/vendored/puppet/lib/puppet/indirector/certificate_status.rb +0 -4
- data/vendored/puppet/lib/puppet/indirector/certificate_status/file.rb +0 -91
- data/vendored/puppet/lib/puppet/indirector/certificate_status/rest.rb +0 -11
- data/vendored/puppet/lib/puppet/indirector/key/ca.rb +0 -16
- data/vendored/puppet/lib/puppet/indirector/key/disabled_ca.rb +0 -22
- data/vendored/puppet/lib/puppet/indirector/ldap.rb +0 -86
- data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +0 -275
- data/vendored/puppet/lib/puppet/provider/aixobject.rb +0 -392
- data/vendored/puppet/lib/puppet/provider/cron/crontab.rb +0 -297
- data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +0 -475
- data/vendored/puppet/lib/puppet/ssl/certificate_authority/autosign_command.rb +0 -45
- data/vendored/puppet/lib/puppet/ssl/certificate_authority/interface.rb +0 -324
- data/vendored/puppet/lib/puppet/ssl/certificate_factory.rb +0 -219
- data/vendored/puppet/lib/puppet/ssl/certificate_revocation_list.rb +0 -111
- data/vendored/puppet/lib/puppet/ssl/inventory.rb +0 -55
- data/vendored/puppet/lib/puppet/type/cron.rb +0 -480
@@ -1,10 +1,6 @@
|
|
1
|
-
#
|
2
1
|
# Group Puppet provider for AIX. It uses standard commands to manage groups:
|
3
2
|
# mkgroup, rmgroup, lsgroup, chgroup
|
4
|
-
|
5
|
-
# Author:: Hector Rivas Gandara <keymon@gmail.com>
|
6
|
-
#
|
7
|
-
require 'puppet/provider/aixobject'
|
3
|
+
require 'puppet/provider/aix_object'
|
8
4
|
|
9
5
|
Puppet::Type.type(:group).provide :aix, :parent => Puppet::Provider::AixObject do
|
10
6
|
desc "Group management for AIX."
|
@@ -13,131 +9,74 @@ Puppet::Type.type(:group).provide :aix, :parent => Puppet::Provider::AixObject d
|
|
13
9
|
defaultfor :operatingsystem => :aix
|
14
10
|
confine :operatingsystem => :aix
|
15
11
|
|
16
|
-
# Provider features
|
17
|
-
has_features :manages_aix_lam
|
18
|
-
has_features :manages_members
|
19
|
-
|
20
12
|
# Commands that manage the element
|
21
13
|
commands :list => "/usr/sbin/lsgroup"
|
22
14
|
commands :add => "/usr/bin/mkgroup"
|
23
15
|
commands :delete => "/usr/sbin/rmgroup"
|
24
16
|
commands :modify => "/usr/bin/chgroup"
|
25
17
|
|
26
|
-
#
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
# AIX attributes to properties mapping.
|
32
|
-
#
|
33
|
-
# Valid attributes to be managed by this provider.
|
34
|
-
# It is a list with of hash
|
35
|
-
# :aix_attr AIX command attribute name
|
36
|
-
# :puppet_prop Puppet property name
|
37
|
-
# :to Method to adapt puppet property to aix command value. Optional.
|
38
|
-
# :from Method to adapt aix command value to puppet property. Optional
|
39
|
-
self.attribute_mapping = [
|
40
|
-
#:name => :name,
|
41
|
-
{:aix_attr => :id, :puppet_prop => :gid },
|
42
|
-
{:aix_attr => :users, :puppet_prop => :members,
|
43
|
-
:from => :users_from_attr},
|
44
|
-
{:aix_attr => :attributes, :puppet_prop => :attributes},
|
45
|
-
]
|
46
|
-
|
47
|
-
#--------------
|
48
|
-
# Command definition
|
49
|
-
|
50
|
-
# Return the IA module arguments based on the resource param ia_load_module
|
51
|
-
def get_ia_module_args
|
52
|
-
if @resource[:ia_load_module]
|
53
|
-
["-R", @resource[:ia_load_module].to_s]
|
54
|
-
else
|
55
|
-
[]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def lscmd(value=@resource[:name])
|
60
|
-
[self.class.command(:list)] +
|
61
|
-
self.get_ia_module_args +
|
62
|
-
[ value]
|
63
|
-
end
|
64
|
-
|
65
|
-
def lsallcmd()
|
66
|
-
lscmd("ALL")
|
67
|
-
end
|
18
|
+
# Provider features
|
19
|
+
has_features :manages_aix_lam
|
20
|
+
has_features :manages_members
|
68
21
|
|
69
|
-
|
70
|
-
#
|
71
|
-
#
|
22
|
+
class << self
|
23
|
+
# Used by the AIX user provider. Returns a hash of:
|
24
|
+
# {
|
25
|
+
# :name => <group_name>,
|
26
|
+
# :gid => <gid>
|
27
|
+
# }
|
72
28
|
#
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
29
|
+
# that matches the group, which can either be the group name or
|
30
|
+
# the gid. Takes an optional set of ia_module_args
|
31
|
+
def find(group, ia_module_args = [])
|
32
|
+
groups = list_all(ia_module_args)
|
33
|
+
|
34
|
+
id_property = mappings[:puppet_property][:id]
|
35
|
+
|
36
|
+
if group.is_a?(String)
|
37
|
+
# Find by name
|
38
|
+
group_hash = groups.find { |cur_group| cur_group[:name] == group }
|
39
|
+
else
|
40
|
+
# Find by gid
|
41
|
+
group_hash = groups.find do |cur_group|
|
42
|
+
id_property.convert_attribute_value(cur_group[:id]) == group
|
43
|
+
end
|
44
|
+
end
|
88
45
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
[@resource[:name]]
|
93
|
-
end
|
46
|
+
unless group_hash
|
47
|
+
raise ArgumentError, _("No AIX group exists with a group name or gid of %{group}!") % { group: group }
|
48
|
+
end
|
94
49
|
|
50
|
+
# Convert :id => :gid
|
51
|
+
id = group_hash.delete(:id)
|
52
|
+
group_hash[:gid] = id_property.convert_attribute_value(id)
|
95
53
|
|
96
|
-
|
97
|
-
# Overwrite get_arguments to add the attributes' arguments
|
98
|
-
def get_arguments(key, value, mapping, objectinfo)
|
99
|
-
# In the case of attributes, return a list of key=value
|
100
|
-
if key == :attributes
|
101
|
-
unless value and value.is_a? Hash
|
102
|
-
raise Puppet::Error, _("Attributes must be a list of pairs key=value on %{resource}[%{name}]") %
|
103
|
-
{ resource: @resource.class.name, name: @resource.name }
|
104
|
-
end
|
105
|
-
return value.select { |k,v| true }.map { |pair| pair.join("=") }
|
54
|
+
group_hash
|
106
55
|
end
|
107
|
-
super(key, value, mapping, objectinfo)
|
108
|
-
end
|
109
56
|
|
110
|
-
|
111
|
-
#
|
112
|
-
hash.select {
|
113
|
-
|k,v| !self.class.attribute_mapping_from.include?(k) and
|
114
|
-
!self.class.attribute_ignore.include?(k)
|
115
|
-
}.inject({}) {
|
116
|
-
|h, array| h[array[0]] = array[1]; h
|
117
|
-
}
|
118
|
-
end
|
57
|
+
# Define some Puppet Property => AIX Attribute (and vice versa)
|
58
|
+
# conversion functions here. This is so we can unit test them.
|
119
59
|
|
120
|
-
|
121
|
-
|
122
|
-
|
60
|
+
def members_to_users(members)
|
61
|
+
return members unless members.is_a?(Array)
|
62
|
+
members.join(',')
|
63
|
+
end
|
123
64
|
|
124
|
-
|
125
|
-
|
126
|
-
param = :attributes
|
127
|
-
cmd = modifycmd({param => filter_attributes(attr_hash)})
|
128
|
-
if cmd
|
129
|
-
begin
|
130
|
-
execute(cmd)
|
131
|
-
rescue Puppet::ExecutionFailure => detail
|
132
|
-
raise Puppet::Error, _("Could not set %{param} on %{resource}[%{name}]: %{detail}") % { param: param, resource: @resource.class.name, name: @resource.name, detail: detail }, detail.backtrace
|
133
|
-
end
|
65
|
+
def users_to_members(users)
|
66
|
+
users.split(',')
|
134
67
|
end
|
135
68
|
end
|
136
69
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
70
|
+
mapping puppet_property: :members,
|
71
|
+
aix_attribute: :users,
|
72
|
+
property_to_attribute: method(:members_to_users),
|
73
|
+
attribute_to_property: method(:users_to_members)
|
141
74
|
|
75
|
+
numeric_mapping puppet_property: :gid,
|
76
|
+
aix_attribute: :id
|
142
77
|
|
78
|
+
# Now that we have all of our mappings, let's go ahead and make
|
79
|
+
# the resource methods (property getters + setters for our mapped
|
80
|
+
# properties + a getter for the attributes property).
|
81
|
+
mk_resource_methods
|
143
82
|
end
|
@@ -95,7 +95,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
|
|
95
95
|
def install(useversion = true)
|
96
96
|
command = [command(:gemcmd), "install"]
|
97
97
|
command += install_options if resource[:install_options]
|
98
|
-
if Puppet.
|
98
|
+
if Puppet::Util::Platform.windows?
|
99
99
|
version = resource[:ensure]
|
100
100
|
command << "-v" << %Q["#{version}"] if (! resource[:ensure].is_a? Symbol) and useversion
|
101
101
|
else
|
@@ -6,7 +6,7 @@ Puppet::Type.type(:package).provide :puppet_gem, :parent => :gem do
|
|
6
6
|
|
7
7
|
has_feature :versionable, :install_options, :uninstall_options
|
8
8
|
|
9
|
-
if Puppet.
|
9
|
+
if Puppet::Util::Platform.windows?
|
10
10
|
# On windows, we put our ruby ahead of anything that already
|
11
11
|
# existed on the system PATH. This means that we do not need to
|
12
12
|
# sort out the absolute path.
|
@@ -325,7 +325,7 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr
|
|
325
325
|
r = s[ri+1,s.length]
|
326
326
|
if arch = r.scan(ARCH_REGEX)[0]
|
327
327
|
a = arch.gsub(/\./, '')
|
328
|
-
|
328
|
+
r.gsub!(ARCH_REGEX, '')
|
329
329
|
end
|
330
330
|
else
|
331
331
|
v = s
|
@@ -71,7 +71,7 @@ class Puppet::Provider::Package::Windows
|
|
71
71
|
|
72
72
|
def self.replace_forward_slashes(value)
|
73
73
|
if value.include?('/')
|
74
|
-
value.gsub
|
74
|
+
value = value.gsub('/', "\\")
|
75
75
|
Puppet.debug('Package source parameter contained /s - replaced with \\s')
|
76
76
|
end
|
77
77
|
value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Puppet::Type.type(:package).provide :zypper, :parent => :rpm do
|
1
|
+
Puppet::Type.type(:package).provide :zypper, :parent => :rpm, :source => :rpm do
|
2
2
|
desc "Support for SuSE `zypper` package manager. Found in SLES10sp2+ and SLES11.
|
3
3
|
|
4
4
|
This provider supports the `install_options` attribute, which allows command-line flags to be passed to zypper.
|
@@ -19,7 +19,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
defaultfor :osfamily => [:archlinux]
|
22
|
-
defaultfor :osfamily => :redhat, :operatingsystemmajrelease => "7"
|
22
|
+
defaultfor :osfamily => :redhat, :operatingsystemmajrelease => ["7", "8"]
|
23
23
|
defaultfor :osfamily => :redhat, :operatingsystem => :fedora
|
24
24
|
defaultfor :osfamily => :suse
|
25
25
|
defaultfor :osfamily => :coreos
|
@@ -16,54 +16,48 @@ Puppet::Type.type(:service).provide :windows, :parent => :service do
|
|
16
16
|
|
17
17
|
has_feature :refreshable
|
18
18
|
|
19
|
-
commands :net => 'net.exe'
|
20
|
-
|
21
19
|
def enable
|
22
|
-
|
23
|
-
raise Puppet::Error.new("Win32 service enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
|
20
|
+
Puppet::Util::Windows::Service.set_startup_mode( @resource[:name], :SERVICE_AUTO_START )
|
24
21
|
rescue => detail
|
25
|
-
raise Puppet::Error.new("Cannot enable
|
22
|
+
raise Puppet::Error.new(_("Cannot enable %{resource_name}, error was: %{detail}") % { resource_name: @resource[:name], detail: detail }, detail )
|
26
23
|
end
|
27
24
|
|
28
25
|
def disable
|
29
|
-
|
30
|
-
raise Puppet::Error.new("Win32 service disable of #{@resource[:name]} failed" ) if( w32ss.nil? )
|
26
|
+
Puppet::Util::Windows::Service.set_startup_mode( @resource[:name], :SERVICE_DISABLED )
|
31
27
|
rescue => detail
|
32
|
-
raise Puppet::Error.new("Cannot disable
|
28
|
+
raise Puppet::Error.new(_("Cannot disable %{resource_name}, error was: %{detail}") % { resource_name: @resource[:name], detail: detail }, detail )
|
33
29
|
end
|
34
30
|
|
35
31
|
def manual_start
|
36
|
-
|
37
|
-
raise Puppet::Error.new("Win32 service manual enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
|
32
|
+
Puppet::Util::Windows::Service.set_startup_mode( @resource[:name], :SERVICE_DEMAND_START )
|
38
33
|
rescue => detail
|
39
|
-
raise Puppet::Error.new("Cannot enable
|
34
|
+
raise Puppet::Error.new(_("Cannot enable %{resource_name} for manual start, error was: %{detail}") % { resource_name: @resource[:name], detail: detail }, detail )
|
40
35
|
end
|
41
36
|
|
42
37
|
def enabled?
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Win32::Service.get_start_type(Win32::Service::SERVICE_SYSTEM_START)
|
38
|
+
start_type = Puppet::Util::Windows::Service.service_start_type(@resource[:name])
|
39
|
+
debug("Service #{@resource[:name]} start type is #{start_type}")
|
40
|
+
case start_type
|
41
|
+
when :SERVICE_AUTO_START,
|
42
|
+
:SERVICE_BOOT_START,
|
43
|
+
:SERVICE_SYSTEM_START
|
50
44
|
:true
|
51
|
-
when
|
45
|
+
when :SERVICE_DEMAND_START
|
52
46
|
:manual
|
53
|
-
when
|
47
|
+
when :SERVICE_DISABLED
|
54
48
|
:false
|
55
49
|
else
|
56
|
-
raise Puppet::Error.new("Unknown start type:
|
50
|
+
raise Puppet::Error.new(_("Unknown start type: %{start_type}") % { start_type: start_type })
|
57
51
|
end
|
58
52
|
rescue => detail
|
59
|
-
raise Puppet::Error.new("Cannot get start type
|
53
|
+
raise Puppet::Error.new(_("Cannot get start type %{resource_name}, error was: %{detail}") % { resource_name: @resource[:name], detail: detail }, detail )
|
60
54
|
end
|
61
55
|
|
62
56
|
def start
|
63
57
|
if enabled? == :false
|
64
58
|
# If disabled and not managing enable, respect disabled and fail.
|
65
59
|
if @resource[:enable].nil?
|
66
|
-
raise Puppet::Error
|
60
|
+
raise Puppet::Error.new(_("Will not start disabled service %{resource_name} without managing enable. Specify 'enable => false' to override.") % { resource_name: @resource[:name] })
|
67
61
|
# Otherwise start. If enable => false, we will later sync enable and
|
68
62
|
# disable the service again.
|
69
63
|
elsif @resource[:enable] == :true
|
@@ -72,35 +66,38 @@ Puppet::Type.type(:service).provide :windows, :parent => :service do
|
|
72
66
|
manual_start
|
73
67
|
end
|
74
68
|
end
|
75
|
-
|
76
|
-
net(:start, @resource[:name])
|
77
|
-
rescue Puppet::ExecutionFailure => detail
|
78
|
-
raise Puppet::Error.new("Cannot start #{@resource[:name]}, error was: #{detail}", detail )
|
69
|
+
Puppet::Util::Windows::Service.start(@resource[:name])
|
79
70
|
end
|
80
71
|
|
81
72
|
def stop
|
82
|
-
|
83
|
-
rescue Puppet::ExecutionFailure => detail
|
84
|
-
raise Puppet::Error.new("Cannot stop #{@resource[:name]}, error was: #{detail}", detail )
|
73
|
+
Puppet::Util::Windows::Service.stop(@resource[:name])
|
85
74
|
end
|
86
75
|
|
87
76
|
def status
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
77
|
+
current_state = Puppet::Util::Windows::Service.service_state(@resource[:name])
|
78
|
+
state = case current_state
|
79
|
+
when :SERVICE_STOPPED,
|
80
|
+
:SERVICE_PAUSED,
|
81
|
+
:SERVICE_STOP_PENDING,
|
82
|
+
:SERVICE_PAUSE_PENDING
|
83
|
+
:stopped
|
84
|
+
when :SERVICE_RUNNING,
|
85
|
+
:SERVICE_CONTINUE_PENDING,
|
86
|
+
:SERVICE_START_PENDING
|
87
|
+
:running
|
93
88
|
else
|
94
|
-
raise Puppet::Error.new("Unknown service state '
|
89
|
+
raise Puppet::Error.new(_("Unknown service state '%{current_state}' for service '%{resource_name}'") % { current_state: current_state, resource_name: @resource[:name] })
|
95
90
|
end
|
96
|
-
debug("Service #{@resource[:name]} is #{
|
91
|
+
debug("Service #{@resource[:name]} is #{current_state}")
|
97
92
|
return state
|
98
|
-
rescue => detail
|
99
|
-
raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}", detail )
|
100
93
|
end
|
101
94
|
|
102
95
|
# returns all providers for all existing services and startup state
|
103
96
|
def self.instances
|
104
|
-
|
97
|
+
services = []
|
98
|
+
Puppet::Util::Windows::Service.services.each do |service_name, _|
|
99
|
+
services.push(new(:name => service_name))
|
100
|
+
end
|
101
|
+
services
|
105
102
|
end
|
106
103
|
end
|
@@ -1,25 +1,21 @@
|
|
1
|
-
#
|
2
1
|
# User Puppet provider for AIX. It uses standard commands to manage users:
|
3
2
|
# mkuser, rmuser, lsuser, chuser
|
4
3
|
#
|
5
4
|
# Notes:
|
6
5
|
# - AIX users can have expiry date defined with minute granularity,
|
7
|
-
# but
|
6
|
+
# but Puppet does not allow it. There is a ticket open for that (#5431)
|
7
|
+
#
|
8
8
|
# - AIX maximum password age is in WEEKs, not days
|
9
9
|
#
|
10
10
|
# See https://puppet.com/docs/puppet/latest/provider_development.html
|
11
11
|
# for more information
|
12
|
-
|
13
|
-
# Author:: Hector Rivas Gandara <keymon@gmail.com>
|
14
|
-
#
|
15
|
-
require 'puppet/provider/aixobject'
|
12
|
+
require 'puppet/provider/aix_object'
|
16
13
|
require 'tempfile'
|
17
14
|
require 'date'
|
18
15
|
|
19
16
|
Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
|
20
17
|
desc "User management for AIX."
|
21
18
|
|
22
|
-
# This will the default provider for this platform
|
23
19
|
defaultfor :operatingsystem => :aix
|
24
20
|
confine :operatingsystem => :aix
|
25
21
|
|
@@ -29,7 +25,6 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
|
|
29
25
|
commands :delete => "/usr/sbin/rmuser"
|
30
26
|
commands :modify => "/usr/bin/chuser"
|
31
27
|
|
32
|
-
commands :lsgroup => "/usr/sbin/lsgroup"
|
33
28
|
commands :chpasswd => "/bin/chpasswd"
|
34
29
|
|
35
30
|
# Provider features
|
@@ -37,296 +32,189 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
|
|
37
32
|
has_features :manages_homedir, :manages_passwords, :manages_shell
|
38
33
|
has_features :manages_expiry, :manages_password_age
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
#end
|
44
|
-
#
|
45
|
-
#verify :groups, "Groups must be comma-separated" do |value|
|
46
|
-
# value !~ /\s/
|
47
|
-
#end
|
48
|
-
|
49
|
-
# User attributes to ignore from AIX output.
|
50
|
-
def self.attribute_ignore
|
51
|
-
["name"]
|
52
|
-
end
|
53
|
-
|
54
|
-
# AIX attributes to properties mapping.
|
55
|
-
#
|
56
|
-
# Valid attributes to be managed by this provider.
|
57
|
-
# It is a list with of hash
|
58
|
-
# :aix_attr AIX command attribute name
|
59
|
-
# :puppet_prop Puppet property name
|
60
|
-
# :to Method to adapt puppet property to aix command value. Optional.
|
61
|
-
# :from Method to adapt aix command value to puppet property. Optional
|
62
|
-
self.attribute_mapping = [
|
63
|
-
{:aix_attr => :pgrp, :puppet_prop => :gid,
|
64
|
-
:to => :gid_to_attr,
|
65
|
-
:from => :gid_from_attr },
|
66
|
-
{:aix_attr => :id, :puppet_prop => :uid},
|
67
|
-
{:aix_attr => :groups, :puppet_prop => :groups},
|
68
|
-
{:aix_attr => :home, :puppet_prop => :home},
|
69
|
-
{:aix_attr => :shell, :puppet_prop => :shell},
|
70
|
-
{:aix_attr => :expires, :puppet_prop => :expiry,
|
71
|
-
:to => :expiry_to_attr,
|
72
|
-
:from => :expiry_from_attr },
|
73
|
-
{:aix_attr => :maxage, :puppet_prop => :password_max_age},
|
74
|
-
{:aix_attr => :minage, :puppet_prop => :password_min_age},
|
75
|
-
{:aix_attr => :pwdwarntime, :puppet_prop => :password_warn_days},
|
76
|
-
{:aix_attr => :attributes, :puppet_prop => :attributes},
|
77
|
-
{ :aix_attr => :gecos, :puppet_prop => :comment },
|
78
|
-
]
|
79
|
-
|
80
|
-
#--------------
|
81
|
-
# Command definition
|
82
|
-
|
83
|
-
# Return the IA module arguments based on the resource param ia_load_module
|
84
|
-
def get_ia_module_args
|
85
|
-
if @resource[:ia_load_module]
|
86
|
-
["-R", @resource[:ia_load_module].to_s]
|
87
|
-
else
|
88
|
-
[]
|
35
|
+
class << self
|
36
|
+
def group_provider
|
37
|
+
@group_provider ||= Puppet::Type.type(:group).provider(:aix)
|
89
38
|
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# List groups and Ids
|
93
|
-
def lsgroupscmd(value=@resource[:name])
|
94
|
-
[command(:lsgroup)] +
|
95
|
-
self.get_ia_module_args +
|
96
|
-
["-a", "id", value]
|
97
|
-
end
|
98
39
|
|
99
|
-
|
100
|
-
|
101
|
-
end
|
40
|
+
# Define some Puppet Property => AIX Attribute (and vice versa)
|
41
|
+
# conversion functions here.
|
102
42
|
|
103
|
-
|
104
|
-
|
105
|
-
end
|
43
|
+
def gid_to_pgrp(provider, gid)
|
44
|
+
group = group_provider.find(gid, provider.ia_module_args)
|
106
45
|
|
107
|
-
|
108
|
-
|
109
|
-
# Puppet does not call to self.<parameter>= method if it does not exists.
|
110
|
-
#
|
111
|
-
# It gets an extra list of arguments to add to the user.
|
112
|
-
[self.class.command(:add)] + self.get_ia_module_args +
|
113
|
-
self.hash2args(@resource.to_hash) +
|
114
|
-
extra_attrs + [@resource[:name]]
|
115
|
-
end
|
116
|
-
|
117
|
-
# Get modify command. Set translate=false if no mapping must be used.
|
118
|
-
# Needed for special properties like "attributes"
|
119
|
-
def modifycmd(hash = property_hash)
|
120
|
-
args = self.hash2args(hash)
|
121
|
-
return nil if args.empty?
|
122
|
-
|
123
|
-
[self.class.command(:modify)] + self.get_ia_module_args +
|
124
|
-
args + [@resource[:name]]
|
125
|
-
end
|
46
|
+
group[:name]
|
47
|
+
end
|
126
48
|
|
127
|
-
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
#--------------
|
132
|
-
# We overwrite the create function to change the password after creation.
|
133
|
-
def create
|
134
|
-
super
|
135
|
-
# Reset the password if needed
|
136
|
-
self.password = @resource[:password] if @resource[:password]
|
137
|
-
end
|
49
|
+
def pgrp_to_gid(provider, pgrp)
|
50
|
+
group = group_provider.find(pgrp, provider.ia_module_args)
|
138
51
|
|
52
|
+
group[:gid]
|
53
|
+
end
|
139
54
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
{ class_name: @resource.class.name, resource_name: @resource.name }
|
146
|
-
end
|
147
|
-
return value.map { |k,v| k.to_s.strip + "=" + v.to_s.strip}
|
55
|
+
def expiry_to_expires(expiry)
|
56
|
+
return '0' if expiry == "0000-00-00" || expiry.to_sym == :absent
|
57
|
+
|
58
|
+
DateTime.parse(expiry, "%Y-%m-%d %H:%M")
|
59
|
+
.strftime("%m%d%H%M%y")
|
148
60
|
end
|
149
61
|
|
150
|
-
|
151
|
-
|
62
|
+
def expires_to_expiry(provider, expires)
|
63
|
+
return :absent if expires == '0'
|
152
64
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
attrs = self.parse_attr_list(entry, nil)
|
158
|
-
if attrs and attrs.include? :id and gid == attrs[:id].to_i
|
159
|
-
groupname = entry.split(" ")[0]
|
65
|
+
unless (match_obj = /\A(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)\z/.match(expires))
|
66
|
+
#TRANSLATORS 'AIX' is the name of an operating system and should not be translated
|
67
|
+
Puppet.warning(_("Could not convert AIX expires date '%{expires}' on %{class_name}[%{resource_name}]") % { expires: expires, class_name: provider.resource.class.name, resource_name: provider.resource.name })
|
68
|
+
return :absent
|
160
69
|
end
|
161
|
-
}
|
162
|
-
groupname
|
163
|
-
end
|
164
|
-
|
165
|
-
# Get the groupname from its id
|
166
|
-
def groupid_by_name(groupname)
|
167
|
-
attrs = self.parse_attr_list(execute(lsgroupscmd(groupname)).split("\n")[0], nil)
|
168
|
-
attrs ? attrs[:id].to_i : nil
|
169
|
-
end
|
170
70
|
|
171
|
-
|
172
|
-
|
173
|
-
if value.is_a? Integer
|
174
|
-
groupname = groupname_by_id(value)
|
175
|
-
#TRANSLATORS 'AIX' is the name of the operating system and should not be translated
|
176
|
-
raise ArgumentError, _("AIX group must be a valid existing group") unless groupname
|
177
|
-
else
|
178
|
-
#TRANSLATORS 'AIX' is the name of the operating system and should not be translated
|
179
|
-
raise ArgumentError, _("AIX group must be a valid existing group") unless groupid_by_name(value)
|
180
|
-
groupname = value
|
71
|
+
month, day, year = match_obj[1], match_obj[2], match_obj[-1]
|
72
|
+
return "20#{year}-#{month}-#{day}"
|
181
73
|
end
|
182
|
-
groupname
|
183
|
-
end
|
184
|
-
|
185
|
-
# The user's primary group. Can be specified numerically or by name.
|
186
|
-
def gid_to_attr(value)
|
187
|
-
verify_group(value)
|
188
|
-
end
|
189
74
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
75
|
+
# We do some validation before-hand to ensure the value's an Array,
|
76
|
+
# a String, etc. in the property. This routine does a final check to
|
77
|
+
# ensure our value doesn't have whitespace before we convert it to
|
78
|
+
# an attribute.
|
79
|
+
def groups_to_groups(groups)
|
80
|
+
if groups =~ /\s/
|
81
|
+
raise ArgumentError, _("Invalid value %{groups}: Groups must be comma separated!") % { groups: groups }
|
82
|
+
end
|
194
83
|
|
195
|
-
|
196
|
-
# a zero padded YYYY-MM-DD HH:MM format
|
197
|
-
def expiry_to_attr(value)
|
198
|
-
# For chuser the expires parameter is a 10-character string in the MMDDhhmmyy format
|
199
|
-
# that is,"%m%d%H%M%y"
|
200
|
-
newdate = '0'
|
201
|
-
if value.is_a? String and value!="0000-00-00"
|
202
|
-
d = DateTime.parse(value, "%Y-%m-%d %H:%M")
|
203
|
-
newdate = d.strftime("%m%d%H%M%y")
|
84
|
+
groups
|
204
85
|
end
|
205
|
-
newdate
|
206
86
|
end
|
207
87
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
88
|
+
mapping puppet_property: :comment,
|
89
|
+
aix_attribute: :gecos
|
90
|
+
|
91
|
+
mapping puppet_property: :expiry,
|
92
|
+
aix_attribute: :expires,
|
93
|
+
property_to_attribute: method(:expiry_to_expires),
|
94
|
+
attribute_to_property: method(:expires_to_expiry)
|
95
|
+
|
96
|
+
mapping puppet_property: :gid,
|
97
|
+
aix_attribute: :pgrp,
|
98
|
+
property_to_attribute: method(:gid_to_pgrp),
|
99
|
+
attribute_to_property: method(:pgrp_to_gid)
|
100
|
+
|
101
|
+
mapping puppet_property: :groups,
|
102
|
+
property_to_attribute: method(:groups_to_groups)
|
103
|
+
|
104
|
+
mapping puppet_property: :home
|
105
|
+
mapping puppet_property: :shell
|
106
|
+
|
107
|
+
numeric_mapping puppet_property: :uid,
|
108
|
+
aix_attribute: :id
|
109
|
+
|
110
|
+
numeric_mapping puppet_property: :password_max_age,
|
111
|
+
aix_attribute: :maxage
|
112
|
+
|
113
|
+
numeric_mapping puppet_property: :password_min_age,
|
114
|
+
aix_attribute: :minage
|
115
|
+
|
116
|
+
numeric_mapping puppet_property: :password_warn_days,
|
117
|
+
aix_attribute: :pwdwarntime
|
118
|
+
|
119
|
+
# Now that we have all of our mappings, let's go ahead and make
|
120
|
+
# the resource methods (property getters + setters for our mapped
|
121
|
+
# properties + a getter for the attributes property).
|
122
|
+
mk_resource_methods
|
123
|
+
|
124
|
+
# Helper function that parses the password from the given
|
125
|
+
# password filehandle. This is here to make testing easier
|
126
|
+
# for #password since we cannot configure Mocha to mock out
|
127
|
+
# a method and have it return a block's value, meaning we
|
128
|
+
# cannot test #password directly (not in a simple and obvious
|
129
|
+
# way, at least).
|
130
|
+
# @api private
|
131
|
+
def parse_password(f)
|
132
|
+
# From the docs, a user stanza is formatted as (newlines are explicitly
|
133
|
+
# stated here for clarity):
|
134
|
+
# <user>:\n
|
135
|
+
# <attribute1>=<value1>\n
|
136
|
+
# <attribute2>=<value2>\n
|
137
|
+
#
|
138
|
+
# First, find our user stanza
|
139
|
+
stanza = f.each_line.find { |line| line =~ /\A#{@resource[:name]}:/ }
|
140
|
+
return :absent unless stanza
|
141
|
+
|
142
|
+
# Now find the password line, if it exists. Note our call to each_line here
|
143
|
+
# will pick up right where we left off.
|
144
|
+
match_obj = nil
|
145
|
+
f.each_line.find do |line|
|
146
|
+
# Break if we find another user stanza. This means our user
|
147
|
+
# does not have a password.
|
148
|
+
break if line =~ /^\S+:$/
|
149
|
+
|
150
|
+
match_obj = /password = (\S+)/.match(line)
|
221
151
|
end
|
222
|
-
|
223
|
-
end
|
152
|
+
return :absent unless match_obj
|
224
153
|
|
225
|
-
|
226
|
-
# helper method for tests
|
227
|
-
# AIX reference indicates this file is ASCII
|
228
|
-
# https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.files/passwd_security.htm
|
229
|
-
Puppet::FileSystem.open("/etc/security/passwd", nil, "r:ASCII")
|
154
|
+
match_obj[1]
|
230
155
|
end
|
231
156
|
|
232
|
-
#--------------------------------
|
233
|
-
# Getter and Setter
|
234
|
-
# When the provider is initialized, create getter/setter methods for each
|
235
|
-
# property our resource type supports.
|
236
|
-
# If setter or getter already defined it will not be overwritten
|
237
|
-
|
238
157
|
#- **password**
|
239
158
|
# The user's password, in whatever encrypted format the local machine
|
240
159
|
# requires. Be sure to enclose any value that includes a dollar sign ($)
|
241
160
|
# in single quotes ('). Requires features manages_passwords.
|
242
161
|
#
|
243
|
-
# Retrieve the password parsing
|
162
|
+
# Retrieve the password parsing the /etc/security/passwd file.
|
244
163
|
def password
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
f.each_line { |l| break if l =~ /^#{user}:\s*$/ }
|
250
|
-
if ! f.eof?
|
251
|
-
f.each_line { |l|
|
252
|
-
# If there is a new user stanza, stop
|
253
|
-
break if l =~ /^\S*:\s*$/
|
254
|
-
# If the password= entry is found, return it, stripping trailing space
|
255
|
-
if l =~ /^\s*password\s*=\s*(\S*)\s*$/
|
256
|
-
password = $1; break;
|
257
|
-
end
|
258
|
-
}
|
164
|
+
# AIX reference indicates this file is ASCII
|
165
|
+
# https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.files/passwd_security.htm
|
166
|
+
Puppet::FileSystem.open("/etc/security/passwd", nil, "r:ASCII") do |f|
|
167
|
+
parse_password(f)
|
259
168
|
end
|
260
|
-
f.close()
|
261
|
-
return password
|
262
169
|
end
|
263
170
|
|
264
171
|
def password=(value)
|
265
172
|
user = @resource[:name]
|
266
173
|
|
267
|
-
# Puppet execute does not support strings as input, only files.
|
268
|
-
# The password is expected to be in an encrypted format given -e is specified:
|
269
|
-
# https://www.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds1/chpasswd.htm
|
270
|
-
# /etc/security/passwd is specified as an ASCII file per the AIX documentation
|
271
|
-
tmpfile = Tempfile.new("puppet_#{user}_pw", :encoding => Encoding::ASCII)
|
272
|
-
tmpfile << "#{user}:#{value}\n"
|
273
|
-
tmpfile.close()
|
274
|
-
|
275
|
-
# Options '-e', '-c', use encrypted password and clear flags
|
276
|
-
# Must receive "user:enc_password" as input
|
277
|
-
# command, arguments = {:failonfail => true, :combine => true}
|
278
|
-
# Fix for bugs #11200 and #10915
|
279
|
-
cmd = [self.class.command(:chpasswd), get_ia_module_args, '-e', '-c'].flatten
|
280
174
|
begin
|
281
|
-
|
282
|
-
#
|
175
|
+
# Puppet execute does not support strings as input, only files.
|
176
|
+
# The password is expected to be in an encrypted format given -e is specified:
|
177
|
+
# https://www.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.cmds1/chpasswd.htm
|
178
|
+
# /etc/security/passwd is specified as an ASCII file per the AIX documentation
|
179
|
+
tempfile = nil
|
180
|
+
tempfile = Tempfile.new("puppet_#{user}_pw", :encoding => Encoding::ASCII)
|
181
|
+
tempfile << "#{user}:#{value}\n"
|
182
|
+
tempfile.close()
|
183
|
+
|
184
|
+
# Options '-e', '-c', use encrypted password and clear flags
|
185
|
+
# Must receive "user:enc_password" as input
|
186
|
+
# command, arguments = {:failonfail => true, :combine => true}
|
187
|
+
# Fix for bugs #11200 and #10915
|
188
|
+
cmd = [self.class.command(:chpasswd), *ia_module_args, '-e', '-c']
|
189
|
+
execute_options = {
|
190
|
+
:failonfail => false,
|
191
|
+
:combine => true,
|
192
|
+
:stdinfile => tempfile.path
|
193
|
+
}
|
194
|
+
output = execute(cmd, execute_options)
|
195
|
+
|
196
|
+
# chpasswd can return 1, even on success (at least on AIX 6.1); empty output
|
197
|
+
# indicates success
|
283
198
|
if output != ""
|
284
199
|
raise Puppet::ExecutionFailure, "chpasswd said #{output}"
|
285
200
|
end
|
286
201
|
rescue Puppet::ExecutionFailure => detail
|
287
|
-
raise Puppet::Error, "Could not set
|
202
|
+
raise Puppet::Error, "Could not set password on #{@resource.class.name}[#{@resource.name}]: #{detail}", detail.backtrace
|
288
203
|
ensure
|
289
|
-
|
204
|
+
if tempfile
|
205
|
+
# Extra close will noop. This is in case the write to our tempfile
|
206
|
+
# fails.
|
207
|
+
tempfile.close()
|
208
|
+
tempfile.delete()
|
209
|
+
end
|
290
210
|
end
|
291
211
|
end
|
292
212
|
|
293
|
-
def
|
294
|
-
|
295
|
-
managed_attributes = [managed_attributes] unless managed_attributes.is_a?(Array)
|
296
|
-
managed_attributes.map {|attr| key, _ = attr.split("="); key.strip.to_sym}
|
297
|
-
end
|
298
|
-
|
299
|
-
def should_include?(key, managed_keys)
|
300
|
-
!self.class.attribute_mapping_from.include?(key) and
|
301
|
-
!self.class.attribute_ignore.include?(key) and
|
302
|
-
managed_keys.include?(key)
|
303
|
-
end
|
304
|
-
|
305
|
-
def filter_attributes(hash)
|
306
|
-
# Return only managed attributes.
|
307
|
-
managed_keys = managed_attribute_keys(hash)
|
308
|
-
results = hash.select {
|
309
|
-
|k,v| should_include?(k, managed_keys)
|
310
|
-
}.inject({}) {
|
311
|
-
|h, array| h[array[0]] = array[1]; h
|
312
|
-
}
|
313
|
-
results
|
314
|
-
end
|
315
|
-
|
316
|
-
def attributes
|
317
|
-
filter_attributes(getosinfo(false))
|
318
|
-
end
|
213
|
+
def create
|
214
|
+
super
|
319
215
|
|
320
|
-
|
321
|
-
|
322
|
-
param = :attributes
|
323
|
-
cmd = modifycmd({param => filter_attributes(attr_hash)})
|
324
|
-
if cmd
|
325
|
-
begin
|
326
|
-
execute(cmd)
|
327
|
-
rescue Puppet::ExecutionFailure => detail
|
328
|
-
raise Puppet::Error, "Could not set #{param} on #{@resource.class.name}[#{@resource.name}]: #{detail}", detail.backtrace
|
329
|
-
end
|
216
|
+
if (password = @resource.should(:password))
|
217
|
+
self.password = password
|
330
218
|
end
|
331
219
|
end
|
332
220
|
|