Skip to content

Instantly share code, notes, and snippets.

@riltsken
Created November 21, 2014 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riltsken/44103d0e495827758fbe to your computer and use it in GitHub Desktop.
Save riltsken/44103d0e495827758fbe to your computer and use it in GitHub Desktop.
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