def _configure_node():
    """Exectutes chef-solo to apply roles and recipes to a node"""
    print("")
    msg = "Cooking..."
    if env.parallel:
        msg = "[{0}]: {1}".format(env.host_string, msg)
    print(msg)
    # Backup last report
    with settings(hide('stdout', 'warnings', 'running'), warn_only=True):
        sudo("mv {0} {0}.1".format(LOGFILE))
    # Build chef-solo command
    cmd = "RUBYOPT=-Ku chef-solo"
    if whyrun:
        cmd += " --why-run"
    cmd += ' -l {0} -j /etc/chef/node.json'.format(env.loglevel)
    if ENABLE_LOGS:
        cmd += ' | tee {0}'.format(LOGFILE)
    if env.loglevel == "debug":
        print("Executing Chef Solo with the following command:\n"
              "{0}".format(cmd))
    with settings(hide('warnings', 'running'), warn_only=True):
        output = sudo(cmd)
    if (output.failed or "FATAL: Stacktrace dumped" in output or
            ("Chef Run complete" not in output and
             "Report handlers complete" not in output)):
        if 'chef-solo: command not found' in output:
            print(
                colors.red(
                    "\nFAILED: Chef Solo is not installed on this node"))
            print(
                "Type 'fix node:{0} deploy_chef' to install it".format(
                    env.host))
            abort("")
        else:
            print(colors.red(
                "\nFAILED: chef-solo could not finish configuring the node\n"))
            import sys
            sys.exit(1)
    else:
        msg = "\n"
        if env.parallel:
            msg += "[{0}]: ".format(env.host_string)
        msg += "SUCCESS: Node correctly configured"
        print(colors.green(msg))
Exectutes chef-solo to apply roles and recipes to a node