コード例 #1
0
def __dump_docker_compose(path, content, already_existed):
    '''
    Dumps

    :param path:
    :param content: the not-yet dumped content
    :return:
    '''
    try:
        dumped = yaml.safe_dump(content, indent=2, default_flow_style=False)
        return __write_docker_compose(path, dumped, already_existed)
    except TypeError as t_err:
        msg = 'Could not dump {0} {1}'.format(content, t_err)
        return __standardize_result(False, msg, None, None)
コード例 #2
0
ファイル: salt_cluster.py プロジェクト: Ch3LL/precipitate
def _add_to_roster(roster, name, host, user, auth, sudo):
    '''
    add a cloud instance to the cluster roster
    '''
    entry = {name: {'host': host, 'user': user}}
    entry[name].update(auth)
    if user != 'root' and sudo:
        entry[name].update({'sudo': True, 'tty': True})

    __salt__['state.single']('file.touch', roster, makedirs=True)
    __salt__['file.blockreplace'](roster,
                                  '# -- begin {0} --'.format(name),
                                  '# -- end {0} --'.format(name),
                                  yaml.safe_dump(entry),
                                  append_if_not_found=True)