Example #1
0
def _run_migration(migration, ansible_context, check_mode, no_stop):
    puts(color_summary('Give ansible user access to couchdb files:'))
    user_args = "user=ansible groups=couchdb append=yes"
    run_ansible_module(migration.source_environment, ansible_context,
                       'couchdb2', 'user', user_args, True, None, False)

    file_args = "path={} mode=0755".format(migration.couchdb2_data_dir)
    run_ansible_module(migration.source_environment, ansible_context,
                       'couchdb2', 'file', file_args, True, None, False)

    puts(color_summary('Copy file lists to nodes:'))
    rsync_files_by_host = prepare_to_sync_files(migration, ansible_context)

    if no_stop:
        stop_couch_context = noop_context()
    else:
        puts(color_summary('Stop couch and reallocate shards'))
        stop_couch_context = stop_couch(migration.all_environments,
                                        ansible_context, check_mode)

    with stop_couch_context:
        execute_file_copy_scripts(migration.target_environment,
                                  list(rsync_files_by_host), check_mode)

    return 0
Example #2
0
def _run_migration(migration, ansible_context, check_mode, no_stop):
    puts(colored.blue('Give ansible user access to couchdb files:'))
    user_args = "user=ansible groups=couchdb append=yes"
    run_ansible_module(
        migration.source_environment, ansible_context, 'couchdb2', 'user', user_args,
        True, None, False
    )

    file_args = "path={} mode=0755".format(migration.couchdb2_data_dir)
    run_ansible_module(
        migration.source_environment, ansible_context, 'couchdb2', 'file', file_args,
        True, None, False
    )

    puts(colored.blue('Copy file lists to nodes:'))
    rsync_files_by_host = prepare_to_sync_files(migration, ansible_context)

    if no_stop:
        stop_couch_context = noop_context()
    else:
        puts(colored.blue('Stop couch and reallocate shards'))
        stop_couch_context = stop_couch(migration.all_environments, ansible_context, check_mode)

    with stop_couch_context:
        execute_file_copy_scripts(migration.target_environment, list(rsync_files_by_host), check_mode)

    return 0