Create a gist now

Instantly share code, notes, and snippets.

@riltsken /add_role.py Secret
Created Nov 21, 2014

What would you like to do?
post plugins ran after the node has been provisioned from its first chef solo run
from littlechef import runner as lc
from littlechef import chef
import os
def execute(node):
"""
Add the node's "real role"
"""
role = None
name = lc.env.host_string
if 'lb' in name:
if 'preview' in name:
role = 'reach_lb_preview'
else:
role = 'reach_lb'
elif 'web' in name:
if 'preview' in name:
role = 'reach_web_preview'
else:
role = 'reach_web'
elif 'prxy' in name:
role = 'reach_proxy'
elif 'sio' in name:
role = 'reach_sio'
if role:
node['run_list'] += ['role[{0}]'.format(role)]
os.remove(chef.save_config(node, force=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment