示例#1
0
def node(*nodes):
    """Selects and configures a list of nodes. 'all' configures all nodes"""
    chef.build_node_data_bag()
    if not len(nodes) or nodes[0] == '':
        abort('No node was given')
    elif nodes[0] == 'all':
        # Fetch all nodes and add them to env.hosts
        for node in lib.get_nodes(env.chef_environment):
            env.hosts.append(node['name'])
        if not len(env.hosts):
            abort('No nodes found in /nodes/')
        message = "Are you sure you want to configure all nodes ({0})".format(
            len(env.hosts))
        if env.chef_environment:
            message += " in the {0} environment".format(env.chef_environment)
        message += "?"
        if not __testing__:
            if not lib.global_confirm(message):
                abort('Aborted by user')
    else:
        # A list of nodes was given
        env.hosts = list(nodes)
    env.all_hosts = list(env.hosts)  # Shouldn't be needed

    # Check whether another command was given in addition to "node:"
    if not (littlechef.__cooking__ and 'node:' not in sys.argv[-1]
            and 'nodes_with_role:' not in sys.argv[-1]):
        # If user didn't type recipe:X, role:Y or deploy_chef,
        # configure the nodes
        with settings():
            execute(_node_runner)
        chef.remove_local_node_data_bag()
示例#2
0
def node(*nodes):
    """Selects and configures a list of nodes. 'all' configures all nodes"""
    chef.build_node_data_bag()
    if not len(nodes) or nodes[0] == '':
        abort('No node was given')
    elif nodes[0] == 'all':
        # Fetch all nodes and add them to env.hosts
        for node in lib.get_nodes(env.chef_environment):
            env.hosts.append(node['name'])
        if not len(env.hosts):
            abort('No nodes found in /nodes/')
        message = "Are you sure you want to configure all nodes ({0})".format(
            len(env.hosts))
        if env.chef_environment:
            message += " in the {0} environment".format(env.chef_environment)
        message += "?"
        if not __testing__:
            if not lib.global_confirm(message):
                abort('Aborted by user')
    else:
        # A list of nodes was given
        env.hosts = list(nodes)
    env.all_hosts = list(env.hosts)  # Shouldn't be needed

    # Check whether another command was given in addition to "node:"
    if not(littlechef.__cooking__ and
            'node:' not in sys.argv[-1] and
            'nodes_with_role:' not in sys.argv[-1]):
        # If user didn't type recipe:X, role:Y or deploy_chef,
        # configure the nodes
        with settings():
            execute(_node_runner)
        chef.remove_local_node_data_bag()
示例#3
0
 def tearDown(self):
     chef.remove_local_node_data_bag()
     super(TestChef, self).tearDown()
示例#4
0
 def tearDown(self):
     chef.remove_local_node_data_bag()
     super(TestChef, self).tearDown()