From 4b75708af592b774b23920745c90e88c04addb3a Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Sat, 10 Feb 2018 20:16:47 -0800 Subject: [PATCH] Created fuction to parse username from $homedir $homedir is pulled from Hiera --- .../lib/puppet/functions/homedir_to_user.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb diff --git a/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb b/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb new file mode 100644 index 0000000..ffd485d --- /dev/null +++ b/puppet/production/site/custom_libs/lib/puppet/functions/homedir_to_user.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:homedir_to_user) do + dispatch :homedir_to_user do + param 'String', :some_path + return_type 'String' + end + + def homedir_to_user(some_path) + some_path.split('/')[-1] + end +end