Exemple #1
0
def initialize_vm(wrapper):
    """
    The VM should have already been downloaded.  This generates SSH keys for
    the user, copies them over, starts the VM, and uses littlechef to bootstrap
    chef solo and required packages.

    Also, it links whatever directories are specified.
    """
    wrapper.generate_ssh_key()

    save_config(wrapper)

    wrapper.start()
    wrapper.copy_ssh_key(password=runner.env.password)
    wrapper.ssh_config(comment=False)

    runner.env.host_string = wrapper.host
    runner.env.host = wrapper.host

    # deploy chef
    runner.plugin("install_omnibus_chef")

    wrapper.snapshot("Post_Chef-Solo_Install")

    # run chef-solo and otherwise set up the node
    local.env["VMRUNWRAPPER_CONF"] = os.path.join(script_location, "vmrunwrapper.conf")
    local.env["PATH"] += ":{0}".format(script_location)

    local["vmwrap"]["up"] & FG

    # take a snapshot
    wrapper.snapshot("Post_Littlechef_Bootstrap")
Exemple #2
0
def main():
    parser = OptionParser()
    parser.add_option("-u", "--username", default="root",
        help="username for new server, defaults to %default")
    parser.add_option("-p", "--password", dest="password",
        help="password for new server")
    parser.add_option("-H", "--hostname", dest="hostname",
        help="hostname or ip of new server")

    (options, args) = parser.parse_args()

    # begin hackery to load config file until littlechef gets fixed (04DEC2012)

    ### CHANGE THE ssh_config VALUE AS NEEDED ###
    ssh_config = "~/.ssh/chef.config"

    lc.env.use_ssh_config = True
    lc.env.ssh_config = _SSHConfig()
    lc.env.ssh_config_path = os.path.expanduser(ssh_config)

    lc.env.user = options.username
    lc.env.password = options.password
    lc.env.host_string = options.hostname
    lc.env.host = options.hostname
    lc.env.node_work_path = "/tmp/chef-solo"
    lc.env.follow_symlinks = False

    ### CHANGE THIS TO POINT TO WHERE YOU SAVED THE FILE ###
    lc.env.encrypted_data_bag_secret = "/etc/chef/data_bag_secret_key.txt"

    # We need the ohai plugins installed before running Chef
    lc.plugin("install_omnibus_chef")
    lc.node(options.hostname)