Created
March 16, 2018 10:44
-
-
Save WhatsARanjit/a021aab0ea6d9c40d0f9023218a750a2 to your computer and use it in GitHub Desktop.
Prepend path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class test::mergepaths ( | |
$envpath = undef, | |
) { | |
$_envpath = $envpath ? { | |
undef => $::path, | |
default => join([$envpath, $::path], ':'), | |
} | |
notify { 'newpath': | |
message => $_envpath, | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@puppet2017 /opt/puppetlabs/puppet/modules]# puppet apply -e 'class { "test::mergepaths": }' | |
Notice: Compiled catalog for puppet2017.3.0.puppetlabs.vm in environment production in 0.04 seconds | |
Notice: /opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin | |
Notice: /Stage[main]/Test::Mergepaths/Notify[newpath]/message: defined 'message' as '/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin' | |
Notice: Applied catalog in 0.32 seconds | |
[root@puppet2017 /opt/puppetlabs/puppet/modules]# puppet apply -e 'class { "test::mergepaths": envpath => "/add/this/path", }' | |
Notice: Compiled catalog for puppet2017.3.0.puppetlabs.vm in environment production in 0.04 seconds | |
Notice: /add/this/path:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin | |
Notice: /Stage[main]/Test::Mergepaths/Notify[newpath]/message: defined 'message' as '/add/this/path:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin' | |
Notice: Applied catalog in 0.26 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment