Skip to content

Instantly share code, notes, and snippets.

@gmillerd
Last active February 17, 2018 07:54
Show Gist options
  • Select an option

  • Save gmillerd/681e44e5d7f5c0e7c37d7ece6d0b54f8 to your computer and use it in GitHub Desktop.

Select an option

Save gmillerd/681e44e5d7f5c0e7c37d7ece6d0b54f8 to your computer and use it in GitHub Desktop.
# misc variables used in clustering node names
# ip address as a long
default['iplong'] = "#{node['ipaddress'].split('.').inject(0) {|t,v| (t << 8 ) + v.to_i} }"
# 255.255.255.255 - ipaddr as long
default['255min'] = "#{4294967295 - (node['ipaddress'].split('.').inject(0) {|t,v| (t << 8 ) + v.to_i}) }"
# ip last octet
default['oct4'] = "#{node['ipaddress'].split('.')[-1] }"
# 255 - ip last octet
default['255oct4'] = "#{255 - (node['ipaddress'].split('.')[-1].to_i) }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment