OpsWorks Ruby returning nil for valid regex test -


in opsworks, i'm trying test number suffix on hostname of given node, , extract number if isn't 1. if number isn't 1, have regex match number:

/([\d]+)$­/ 

which run against node naming scheme follows pattern:

  • node1
  • node2
  • node3
  • node(n...)

i've verified works using rubular: http://rubular.com/r/ei0kqjaxqn

however, when run against instance opsworks, match returns nil, no matter number hostname has @ end. opsworks agent version latest @ time of writing (4023), using chef 12.13.37.

this code in cookbook trying use matched number:

short_app_name.to_s + node['hostname'][/([\d]+)$­/, 1].to_s + '.' + app['domains'].first 

the run fails type error no implicit conversion of nil string. however, regex searches against property work earlier in recipe, when checking node's number suffix. there different method should using extract node's suffix?


edit: app['domains'].first populated. line still fails same type error if swapped out domain.com.

when copy regex , paste terminal test, there's soft hyphen character after dollar sign @ end of regex, removing makes things work:

the website isn't showing when copy terminal, screenshot shows issue:

enter image description here

that second line ('irb(main):002:0') copy/pasted cookbook code, character "\xc2\xad"


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -