示例#1
0
def sync_full_manifest(manifest):
    cloud = cloudseed.cloud.Cloud(__opts__)
    vm_ = cloud.vm_profile('master')

    keyname = '%s-%s' % (env.location_name(), env.env_name())

    filename = os.path.join(env.current_env_path(), 'salt', '%s.pem' % keyname)

    manifest.add(filename, '/etc/salt/cloud.pem')

    # changing the path to the private_key file to work on
    # the bootstrapped master
    providers = filesystem.read_file(__opts__['providers_config'])

    providers_data = yaml.load(providers)
    alias, driver = vm_['provider'].split(':')
    master_provider = providers_data[alias]

    master_provider['private_key'] = '/etc/salt/cloud.pem'
    cloud_providers = yaml.safe_dump(providers_data, default_flow_style=False)

    manifest.remove('cloudseed/current/salt/cloud.providers')

    manifest.add(writers.write_stringio(cloud_providers),
                 '/etc/salt/cloud.providers')
示例#2
0
def sync_full_manifest(manifest):
    cloud = cloudseed.cloud.Cloud(__opts__)
    vm_ = cloud.vm_profile('master')

    keyname = '%s-%s' % (env.location_name(), env.env_name())

    filename = os.path.join(
        env.current_env_path(),
        'salt',
        '%s.pem' % keyname)

    manifest.add(filename, '/etc/salt/cloud.pem')

    # changing the path to the private_key file to work on
    # the bootstrapped master
    providers = filesystem.read_file(__opts__['providers_config'])

    providers_data = yaml.load(providers)
    alias, driver = vm_['provider'].split(':')
    master_provider = providers_data[alias]

    master_provider['private_key'] = '/etc/salt/cloud.pem'
    cloud_providers = yaml.safe_dump(providers_data, default_flow_style=False)

    manifest.remove('cloudseed/current/salt/cloud.providers')

    manifest.add(
        writers.write_stringio(cloud_providers),
        '/etc/salt/cloud.providers')
示例#3
0
def security_group_name(name=None):
    location_name = env.location_name()
    env_name = env.env_name()

    if name:
        return 'cloudseed-%s-%s-%s' % (location_name, env_name, name)

    return 'cloudseed-%s-%s' % (location_name, env_name)
示例#4
0
def security_group_name(name=None):
    location_name = env.location_name()
    env_name = env.env_name()

    if name:
        return 'cloudseed-%s-%s-%s' % (location_name, env_name, name)

    return 'cloudseed-%s-%s' % (location_name, env_name)
示例#5
0
def run(argv):
    args = docopt(__doc__, argv=argv)
    profile = args['<profile>']
    tag = 'cloudseed-%s-%s-%s' % (env.location_name(), env.env_name(), profile)

    # TODO ensure we have a bootstrapped master
    # bail if we have not
    if args.get('--local', False):
        cloudseed.agent.actions.execute_profile(profile, tag)
    else:
        commands.deploy(profile, tag)
示例#6
0
def run(argv):
    tag = 'cloudseed-%s-%s-master' % (env.location_name(), env.env_name())
    prefix = os.path.join(env.current_env_path(), 'salt')

    saltcloud.execute_profile(
        'master',
        tag=tag,
        cloud_config=os.path.join(prefix, 'cloud'),
        cloud_providers=os.path.join(prefix, 'cloud.providers'),
        cloud_profiles=os.path.join(prefix, 'cloud.profiles'),
        master_config=os.path.join(prefix, 'master'))
示例#7
0
def run(argv):
    tag = "cloudseed-%s-%s-master" % (env.location_name(), env.env_name())
    prefix = os.path.join(env.current_env_path(), "salt")

    saltcloud.execute_profile(
        "master",
        tag=tag,
        cloud_config=os.path.join(prefix, "cloud"),
        cloud_providers=os.path.join(prefix, "cloud.providers"),
        cloud_profiles=os.path.join(prefix, "cloud.profiles"),
        master_config=os.path.join(prefix, "master"),
    )
示例#8
0
def bootstrap_master(vm_, cloud):
    provider = cloud.provider_profile_full(vm_)

    provider['ssh_interface'] = 'public_ips'
    append_data = {}

    if not provider.get('keyname', False):
        keyname = '%s-%s' % (env.location_name(), env.env_name())

        filename = os.path.join(
            env.current_env_path(),
            'salt',
            '%s.pem' % keyname)

        bootstrap_create_keypair(keyname, filename)

        # set it for the current command
        provider['keyname'] = keyname
        provider['private_key'] = filename

        append_data['keyname'] = keyname
        append_data['private_key'] = 'cloudseed/current/salt/%s.pem' % keyname

    else:
        if not os.path.isabs(provider['private_key']):
            new_path = os.path.abspath(provider['private_key'])
            provider['private_key'] = new_path

    groups = bootstrap_master_security_groups(vm_, provider)
    append_data['securitygroup'] = groups

    # write down and new data
    if append_data:
        provider_bytes = filesystem.read_file(cloud.opts['providers_config'])
        provider_data = yaml.load(provider_bytes)
        alias, driver = vm_['provider'].split(':')

        target = provider_data[alias]
        target.update(append_data)
        writers.write_yaml(cloud.opts['providers_config'], provider_data)
示例#9
0
def bootstrap_master(vm_, cloud):
    provider = cloud.provider_profile_full(vm_)

    provider['ssh_interface'] = 'public_ips'
    append_data = {}

    if not provider.get('keyname', False):
        keyname = '%s-%s' % (env.location_name(), env.env_name())

        filename = os.path.join(env.current_env_path(), 'salt',
                                '%s.pem' % keyname)

        bootstrap_create_keypair(keyname, filename)

        # set it for the current command
        provider['keyname'] = keyname
        provider['private_key'] = filename

        append_data['keyname'] = keyname
        append_data['private_key'] = 'cloudseed/current/salt/%s.pem' % keyname

    else:
        if not os.path.isabs(provider['private_key']):
            new_path = os.path.abspath(provider['private_key'])
            provider['private_key'] = new_path

    groups = bootstrap_master_security_groups(vm_, provider)
    append_data['securitygroup'] = groups

    # write down and new data
    if append_data:
        provider_bytes = filesystem.read_file(cloud.opts['providers_config'])
        provider_data = yaml.load(provider_bytes)
        alias, driver = vm_['provider'].split(':')

        target = provider_data[alias]
        target.update(append_data)
        writers.write_yaml(cloud.opts['providers_config'], provider_data)