def main():
    debug = ['1', 'true', 'on', 'ON'] in os.environ.get('DEBUG', '')
    logging.basicConfig(format='%(asctime)s - bootstrapping - %(levelname)s - %(message)s', level=('DEBUG'
                         if debug else 'INFO'))
    if debug:
        logging.warning('variable DEBUG was set, dropping you to a bash shell. (unset DEBUG to avoid this)')
        os.execlpe('bash', 'bash', dict(os.environ))

    placeholders = get_placeholders()

    write_certificates(placeholders)

    config = yaml.load(pystache_render(TEMPLATE, placeholders))
    config.update(get_dcs_config(config, placeholders))

    user_config = yaml.load(os.environ.get('PATRONI_CONFIGURATION', '')) or {}
    if not isinstance(user_config, dict):
        raise ValueError('PATRONI_CONFIGURATION should contain a dict, yet it is a {}'.format(type(user_config)))

    config = deep_update(user_config, config)

    # Ensure replication is available
    if not any(['replication' in i for i in config['postgresql']['pg_hba']]):
        rep_hba = 'hostssl replication {} 0.0.0.0/0 md5'.format(config['postgresql']['replication']['username'])
        config['postgresql']['pg_hba'].insert(0, rep_hba)

    # Patroni configuration
    patroni_configfile = os.path.join(placeholders['PGHOME'], 'postgres.yml')
    write_configuration(config, patroni_configfile)

    configure_patronictl(patroni_configfile, os.path.join(placeholders['PGHOME'], '.config', 'patroni',
                         'patronictl.yaml'))

    # WAL-E
    write_wale_command_environment(placeholders)

    # # We run cron, to schedule recurring tasks on the node
    logging.info('Starting up cron')
    write_crontab(placeholders, os.environ.get('PATH'))
    subprocess.call(['/usr/bin/sudo', '/usr/sbin/cron'])

    # # We run 1 backup, with INITIAL_BACKUP set
    subprocess.Popen(['/bin/bash', '/postgres_backup.sh', placeholders['WALE_ENV_DIR'], placeholders['PGDATA']],
                     env={'PATH': os.environ['PATH'], 'INITIAL_BACKUP': '1'})

    os.execlpe('patroni', 'patroni', patroni_configfile, {'PATH': os.environ.get('PATH')})
dataset/ETHPy150Open zalando/spilo/postgres-appliance/postgres_ha.py/main/swapped operands of `in`