Ask Your Question
2

Get last character of hostname

asked 2014-08-29 01:11:59 -0500

adrianwxn gravatar image

Hello,

I have a cluster composed of the following nodes linux01a linux02b I need to get the last letter of the node for some customization.

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2014-08-29 14:00:07 -0500

jzimmerman gravatar image

The template method is good if you need to grab the last character. If you just want to match on it you can do something like...

case $::hostname {

  /(b$)/:  { stuff for b here }

  /(a$)/:  {stuff for a here }

  default: { default stuff here }

}
edit flag offensive delete link more
3

answered 2014-08-29 10:40:05 -0500

ramindk gravatar image

I usually use inline_templates.

 $my_cluster = inline_template('<%= @hostname[-1,1] %>')
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

Stats

Asked: 2014-08-29 01:11:59 -0500

Seen: 286 times

Last updated: Aug 29 '14