def configure(): """Configure node using existing config file""" # Check that a node has been selected if not env.host_string: msg = 'no node specified\n' msg += 'Usage:\n cook node:MYNODE configure' msg += '\n cook node:all configure' abort(msg) lib.print_header("Configuring {0}".format(env.host_string)) # Read node data and configure node node = lib.get_node(env.host_string) chef.sync_node(node)
def role(role): """Apply the given role to a node, ignoring any existing configuration If no nodes/hostname.json file exists, it creates one """ # Check that a node has been selected if not env.host_string: abort('no node specified\nUsage: cook node:MYNODE role:MYROLE') lib.print_header( "Applying role '{0}' to node {1}".format(role, env.host_string)) # Now create configuration and sync node data = {"run_list": ["role[{0}]".format(role)]} chef.sync_node(data)