Esempio n. 1
0
def deploy_chef(gems="no", ask="yes", version="0.9"):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort('no node specified\nUsage: cook node:MYNODE deploy_chef')
    chef_versions = ["0.9", "0.10"]
    if version not in chef_versions:
        abort('Wrong Chef version specified. Valid versions are {0}'.format(
            ", ".join(chef_versions)))
    distro_type, distro = solo.check_distro()
    if ask == "yes":
        message = '\nAre you sure you want to install Chef'
        message += 'at the node {0}'.format(env.host_string)
        if gems == "yes":
            message += ', using gems for "{0}"?'.format(distro)
        else:
            message += ', using "{0}" packages?'.format(distro)
        if not confirm(message):
            abort('Aborted by user')
    else:
        if gems == "yes":
            method = ' using gems for "{0}"'.format(distro)
        else:
            method = ' {0} using "{1}" packages'.format(version, distro)
        print("Deploying Chef {0}...".format(method))

    solo.install(distro_type, distro, gems, version)
    solo.configure()
Esempio n. 2
0
def deploy_chef(gems="no", ask="yes", version="0.10",
    distro_type=None, distro=None, stop_client='yes'):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort('no node specified\nUsage: fix node:MYNODE deploy_chef')
    chef_versions = ["0.9", "0.10"]
    if version not in chef_versions:
        abort('Wrong Chef version specified. Valid versions are {0}'.format(
            ", ".join(chef_versions)))
    if distro_type is None and distro is None:
        distro_type, distro = solo.check_distro()
    elif distro_type is None or distro is None:
        abort('Must specify both or neither of distro_type and distro')
    if ask == "yes":
        message = '\nAre you sure you want to install Chef {0}'.format(version)
        message += ' at the node {0}'.format(env.host_string)
        if gems == "yes":
            message += ', using gems for "{0}"?'.format(distro)
        else:
            message += ', using "{0}" packages?'.format(distro)
        if not confirm(message):
            abort('Aborted by user')
    else:
        if gems == "yes":
            method = 'using gems for "{0}"'.format(distro)
        else:
            method = '{0} using "{1}" packages'.format(version, distro)
        print("Deploying Chef {0}...".format(method))

    if not __testing__:
        solo.install(distro_type, distro, gems, version, stop_client)
        solo.configure()
Esempio n. 3
0
def deploy_chef(gems="no", ask="yes", version="0.9"):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort("no node specified\nUsage: cook node:MYNODE deploy_chef")
    chef_versions = ["0.9", "0.10"]
    if version not in chef_versions:
        abort("Wrong Chef version specified. Valid versions are {0}".format(", ".join(chef_versions)))
    distro_type, distro = solo.check_distro()
    if ask == "yes":
        message = "\nAre you sure you want to install Chef"
        message += "at the node {0}".format(env.host_string)
        if gems == "yes":
            message += ', using gems for "{0}"?'.format(distro)
        else:
            message += ', using "{0}" packages?'.format(distro)
        if not confirm(message):
            abort("Aborted by user")
    else:
        if gems == "yes":
            method = ' using gems for "{0}"'.format(distro)
        else:
            method = ' {0} using "{1}" packages'.format(version, distro)
        print ("Deploying Chef {0}...".format(method))

    solo.install(distro_type, distro, gems, version)
    solo.configure()
Esempio n. 4
0
def deploy_chef(gems="no", ask="yes", version="0.10",
    distro_type=None, distro=None, stop_client='yes'):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort('no node specified\nUsage: fix node:MYNODES deploy_chef')
    chef_versions = ["0.9", "0.10"]
    if version not in chef_versions:
        abort('Wrong Chef version specified. Valid versions are {0}'.format(
            ", ".join(chef_versions)))
    if distro_type is None and distro is None:
        distro_type, distro = solo.check_distro()
    elif distro_type is None or distro is None:
        abort('Must specify both or neither of distro_type and distro')
    if ask == "yes":
        message = '\nAre you sure you want to install Chef {0}'.format(version)
        message += ' at the node {0}'.format(env.host_string)
        if gems == "yes":
            message += ', using gems for "{0}"?'.format(distro)
        else:
            message += ', using "{0}" packages?'.format(distro)
        if not confirm(message):
            abort('Aborted by user')
    else:
        if gems == "yes":
            method = 'using gems for "{0}"'.format(distro)
        else:
            method = '{0} using "{1}" packages'.format(version, distro)
        print("Deploying Chef {0}...".format(method))

    if not __testing__:
        solo.install(distro_type, distro, gems, version, stop_client)
        solo.configure()
Esempio n. 5
0
def deploy_chef(gems="no", ask="yes", version="0.10", distro_type=None,
                distro=None, platform=None, stop_client='yes', method=None):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort('no node specified\nUsage: fix node:MYNODES deploy_chef')
    deprecated_parameters = [distro_type, distro, platform]
    if any(param is not None for param in deprecated_parameters) or gems != 'no':
        print("DeprecationWarning: the parameters 'gems', distro_type',"
              " 'distro' and 'platform' will no longer be supported "
              "in future versions of LittleChef. Use 'method' instead")
    if distro_type is None and distro is None:
        distro_type, distro, platform = solo.check_distro()
    elif distro_type is None or distro is None:
        abort('Must specify both or neither of distro_type and distro')
    if method:
        if method not in ['omnibus', 'gentoo', 'pacman']:
            abort('Invalid omnibus method {0}. Supported methods are '
                  'omnibus, gentoo and pacman'.format(method))
        msg = "{0} using the {1} installer".format(version, method)
    else:
        if gems == "yes":
            msg = 'using gems for "{0}"'.format(distro)
        else:
            msg = '{0} using "{1}" packages'.format(version, distro)
    if method == 'omnibus' or ask == "no" or littlechef.noninteractive:
        print("Deploying Chef {0}...".format(msg))
    else:
        message = ('\nAre you sure you want to install Chef '
                   '{0} on node {1}?'.format(msg, env.host_string))
        if not confirm(message):
            abort('Aborted by user')

    _configure_fabric_for_platform(platform)

    if not __testing__:
        solo.install(distro_type, distro, gems, version, stop_client, method)
        solo.configure()

        # Build a basic node file if there isn't one already
        # with some properties from ohai
        with settings(hide('stdout'), warn_only=True):
            output = sudo('ohai -l warn')
        if output.succeeded:
            try:
                ohai = json.loads(output)
            except ValueError:
                abort("Could not parse ohai's output"
                      ":\n  {0}".format(output))
            node = {"run_list": []}
            for attribute in ["ipaddress", "platform", "platform_family",
                         "platform_version"]:
                if ohai.get(attribute):
                    node[attribute] = ohai[attribute]
            chef.save_config(node)
Esempio n. 6
0
def deploy_chef(gems="no", ask="yes", version="0.10",
    distro_type=None, distro=None, platform=None, stop_client='yes'):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort('no node specified\nUsage: fix node:MYNODES deploy_chef')
    chef_versions = ["0.9", "0.10"]
    if version not in chef_versions:
        abort('Wrong Chef version specified. Valid versions are {0}'.format(
            ", ".join(chef_versions)))
    if distro_type is None and distro is None:
        distro_type, distro, platform = solo.check_distro()
    elif distro_type is None or distro is None:
        abort('Must specify both or neither of distro_type and distro')
    if ask == "yes":
        message = '\nAre you sure you want to install Chef {0}'.format(version)
        message += ' on node {0}'.format(env.host_string)
        if gems == "yes":
            message += ', using gems for "{0}"?'.format(distro)
        else:
            message += ', using "{0}" packages?'.format(distro)
        if not confirm(message):
            abort('Aborted by user')
    else:
        if gems == "yes":
            method = 'using gems for "{0}"'.format(distro)
        else:
            method = '{0} using "{1}" packages'.format(version, distro)
        print("Deploying Chef {0}...".format(method))

    _configure_fabric_for_platform(platform)

    if not __testing__:
        solo.install(distro_type, distro, gems, version, stop_client)
        solo.configure()

        # Build a basic node file if there isn't one already with some properties from ohai
        with settings(hide('stdout'), warn_only=True):
            output = sudo('ohai -l warn')
        if output.succeeded:
            try:
                ohai = json.loads(output)
            except json.JSONDecodeError:
                abort("Could not parse ohai's output"
                      ":\n  {0}".format(output))
            node = {"run_list": []}
            for prop in ["ipaddress", "platform", "platform_family",
                         "platform_version"]:
                if ohai[prop]:
                    node[prop] = ohai[prop]
            chef.save_config(node)
Esempio n. 7
0
def deploy_chef(gems="no", ask="yes", version="0.9"):
    """Install chef-solo on a node"""
    if not env.host_string:
        abort('no node specified\nUsage: cook node:MYNODE deploy_chef')
    chef_versions = ["0.9", "0.10"]
    if version not in chef_versions:
        abort('Wrong Chef version specified. Valid versions are {0}'.format(
            ", ".join(chef_versions)))
    distro_type, distro = solo.check_distro()
    message = '\nAre you sure you want to install Chef at the node {0}'.format(
        env.host_string)
    if gems == "yes":
        message += ', using gems for "{0}"?'.format(distro)
    else:
        message += ', using "{0}" packages?'.format(distro)
    if ask != "no" and not confirm(message):
        abort('Aborted by user')

    solo.install(distro_type, distro, gems, version)
    solo.configure()