def deployment_server_init():
    ret_status = 0
    serv = _get_redis_serv()
    is_deployment_server = __grains__.get('deployment_server')
    if not is_deployment_server:
        return ret_status
    deploy_user = __grains__.get('deployment_repo_user')
    repo_config = __pillar__.get('repo_config')
    for repo in repo_config:
        config = get_config(repo)
        # Clone repo from upstream or init repo with no upstream
        if not __salt__['file.directory_exists'](config['location'] + '/.git'):
            if config['upstream']:
                cmd = '/usr/bin/git clone %s/.git %s' % (config['upstream'],
                                                         config['location'])
                status = __salt__['cmd.retcode'](cmd, runas=deploy_user,
                                                 umask=002)
                if status != 0:
                    ret_status = 1
                    continue
                # We don't check the checkout_submodules config flag here
                # on purpose. The deployment server should always have a
                # fully recursive clone and minions should decide whether
                # or not they'll use the submodules. This avoids consistency
                # issues in the case where submodules are later enabled, but
                # someone forgets to check them out.
                cmd = '/usr/bin/git submodule update --init --recursive'
                status = __salt__['cmd.retcode'](cmd, runas=deploy_user,
                                                 umask=002,
                                                 cwd=config['location'])

                # http will likely be used as deploy targets' remote transport.
                # submodules don't know how to work properly via http
                # remotes unless info/refs and other files are up to date.
                # This will call git update-server-info for each of the
                # checkouts inside of the .git/modules/<modulename> directory.
                cmd = ("""git submodule foreach --recursive """
                       """'cd $(sed "s/^gitdir: //" .git) && """
                       """git update-server-info'""")

                status = __salt__['cmd.retcode'](cmd, runas=deploy_user,
                                                 umask=002,
                                                 cwd=config['location'])

                # Install a post-checkout hook to run update-server-info
                # for each submodule.  This command needs to be run
                # every time the repository is changed.
                hook_directory = os.path.join(
                    config['location'], '.git', 'hooks'
                )
                post_checkout_path = os.path.join(
                    hook_directory, 'post-checkout'
                )
                post_checkout = open(post_checkout_path, 'w')
                post_checkout.write(cmd + "\n")
                post_checkout.close()
                os.chmod(post_checkout_path, 775)

                # we should run this on post-commit too, so just symlink
                # post-commit to post-checkout
                post_commit_path = os.path.join(hook_directory, 'post-commit')
                os.symlink(post_checkout_path, post_commit_path)
                # chown the hooks to the deploy_user
                deploy_uid = pwd.getpwnam(deploy_user).pw_uid
                os.chown(post_checkout_path, deploy_uid, -1)
                os.lchown(post_commit_path, deploy_uid, -1)
            else:
                cmd = '/usr/bin/git init %s' % (config['location'])
                status = __salt__['cmd.retcode'](cmd, runas=deploy_user,
                                                 umask=002)
            if status != 0:
                ret_status = 1
                continue
            # git clone does ignores umask and does explicit mkdir with 755
            __salt__['file.set_mode'](config['location'], 2775)
            # Set the repo name in the repo's config
            cmd = 'git config deploy.repo-name %s' % repo
            status = __salt__['cmd.retcode'](cmd, cwd=config['location'],
                                             runas=deploy_user, umask=002)
            if status != 0:
                ret_status = 1
            # Ensure checkout-submodules is also configured for trigger
            if config['checkout_submodules']:
                cmd = 'git config deploy.checkout-submodules true'
            else:
                cmd = 'git config deploy.checkout-submodules false'
            status = __salt__['cmd.retcode'](cmd, cwd=config['location'],
                                             runas=deploy_user, umask=002)
            if status != 0:
                ret_status = 1
    return ret_status
Starts all the watchers.
dataset/ETHPy150Open trebuchet-deploy/trebuchet/modules/deploy.py/deployment_server_init--crossover with--dataset/ETHPy150Open circus-tent/circus/circus/arbiter.py/Arbiter.start