Ask Your Question
0

How to use the chop funtion in stdlib to remove the last character of a string in puppet 4.10

asked 2018-05-18 03:50:25 -0500

shajics gravatar image

updated 2018-05-18 17:26:59 -0500

binford2k gravatar image

I tried this, but getting the same name as the output.

$database_name = "${facts['database_name']}"
$trundbname = chop("${database_name}")
notify{"Ouput of trundbname = ${trundbname}":}

Any thoughts would be really helpful

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-05-18 17:29:49 -0500

binford2k gravatar image

updated 2018-05-18 17:30:17 -0500

That function works as you want. You should check your strings carefully. It's likely that you have characters you're not expecting.

$ puppet apply -e 'notice(chop("foobar"))'
Notice: Scope(Class[main]): fooba
Notice: Compiled catalog for ganymede.corp.puppetlabs.net in environment production in 0.16 seconds
Notice: Applied catalog in 0.04 seconds

Side note: This isn't Bash. You don't have to wrap variables in strings if they're already a string. In other words, "${facts['database_name']}" is redundant. Just use the variable:${facts['database_name']

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-05-18 03:50:25 -0500

Seen: 50 times

Last updated: May 18