diff options
| author | Nicolas Vigier <boklm@mageia.org> | 2013-06-19 19:15:59 +0000 |
|---|---|---|
| committer | Nicolas Vigier <boklm@mageia.org> | 2013-06-19 19:15:59 +0000 |
| commit | df7e540f6ad7385badb91e385e79a583789f3649 (patch) | |
| tree | d4fe5b854539953b90177d72ca7852e81e555eb2 /modules/mga_common/lib | |
| parent | 187fb82b596357d0450c75d728bad2004eae6e0e (diff) | |
| download | puppet-df7e540f6ad7385badb91e385e79a583789f3649.tar puppet-df7e540f6ad7385badb91e385e79a583789f3649.tar.gz puppet-df7e540f6ad7385badb91e385e79a583789f3649.tar.bz2 puppet-df7e540f6ad7385badb91e385e79a583789f3649.tar.xz puppet-df7e540f6ad7385badb91e385e79a583789f3649.zip | |
Rename mga-common module to mga_common.
New puppet version doesn't like modules with a - in their name.
Diffstat (limited to 'modules/mga_common/lib')
4 files changed, 42 insertions, 0 deletions
diff --git a/modules/mga_common/lib/puppet/parser/functions/group_members.rb b/modules/mga_common/lib/puppet/parser/functions/group_members.rb new file mode 100644 index 00000000..c5cecbe8 --- /dev/null +++ b/modules/mga_common/lib/puppet/parser/functions/group_members.rb @@ -0,0 +1,10 @@ +require 'etc' +# group_members($group) +# -> return a array with the login of the group members + +module Puppet::Parser::Functions + newfunction(:group_members, :type => :rvalue) do |args| + group = args[0] + return Etc.getgrnam(group).mem + end +end diff --git a/modules/mga_common/lib/puppet/parser/functions/hash_keys.rb b/modules/mga_common/lib/puppet/parser/functions/hash_keys.rb new file mode 100644 index 00000000..3a926bee --- /dev/null +++ b/modules/mga_common/lib/puppet/parser/functions/hash_keys.rb @@ -0,0 +1,10 @@ +module Puppet::Parser::Functions + newfunction(:hash_keys, :type => :rvalue) do |args| + unless args[0].is_a?(Hash) + Puppet.warning "hash_keys takes one argument, the input hash" + nil + else + args[0].keys + end + end +end diff --git a/modules/mga_common/lib/puppet/parser/functions/hash_merge.rb b/modules/mga_common/lib/puppet/parser/functions/hash_merge.rb new file mode 100644 index 00000000..375bffa4 --- /dev/null +++ b/modules/mga_common/lib/puppet/parser/functions/hash_merge.rb @@ -0,0 +1,11 @@ +module Puppet::Parser::Functions + newfunction(:hash_merge, :type => :rvalue) do |args| + unless args[0].is_a?(Hash) and args[1].is_a?(Hash) + Puppet.warning "hash_merge takes two arguments" + nil + else + print "hash_merge\n" + args[0].merge(args[1]) + end + end +end diff --git a/modules/mga_common/lib/puppet/parser/functions/str_join.rb b/modules/mga_common/lib/puppet/parser/functions/str_join.rb new file mode 100644 index 00000000..de97bfb5 --- /dev/null +++ b/modules/mga_common/lib/puppet/parser/functions/str_join.rb @@ -0,0 +1,11 @@ +# str_join($array, $sep) +# -> return a string created by converting each element of the array to +# a string, separated by $sep + +module Puppet::Parser::Functions + newfunction(:str_join, :type => :rvalue) do |args| + array = args[0] + sep = args[1] + return array.join(sep) + end +end |
