# Path: nuka/tasks/apt.py
# GPG_HEADER = b'-----BEGIN PGP PUBLIC KEY BLOCK-----'
# def apt_watcher(delay, fd):
#     def watcher(task, process):
#     def __init__(self, name=None, src=None, key=None, update=True, **kwargs):
#     def add_key(self, key):
#     def do(self):
#     def diff(self):
#     def __init__(self, cache=None, **kwargs):
#     def do(self):
#     def __init__(self, update_cache=None, **kwargs):
#     def do(self):
#     def __init__(self, packages, **kwargs):
#     def do(self):
#     def __init__(self, packages=None, debconf=None,
#                  debian_frontend='noninteractive', **kwargs):
#     def do(self):
#     def __init__(self, selections=None, **kwargs):
#     def do(self):
#     def __init__(self, packages=None, debconf=None,
#                  debian_frontend='noninteractive', debian_priority=None,
#                  update_cache=None, install_recommends=False, **kwargs):
#     def get_packages_list(self, packages):
#     def do(self):
#     def diff(self):
# class source(Task):
# class update(Task):
# class list(Task):
# class search(Task):
# class upgrade(Task):
# class debconf_set_selections(Task):
# class install(Task):
# 
# Path: nuka/tasks/mysql.py
# class my_cnf(Task):
# class set_root_password(my_cnf):
# class create_db(Task):
# class execute(Task):
#     def __init__(self, password=None, switch_user='root', **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, password=None, **kwargs):
#     def do(self):
#     def __init__(self, name=None, user=None, password=None, **kwargs):
#     def do(self):
#     def __init__(self, sql=None, **kwargs):
#     def do(self):
# 
# Path: nuka/tasks/file.py
# class exists(Task):
# class mkdir(Task):
# class mkdirs(Task):
# class rm(Task):
# class mv(Task):
# class chmod(Task):
# class chown(Task):
# class put(Task):
# class scripts(put):
# class cat(Task):
# class update(Task):
#     def __init__(self, dst=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, dst=None, mod=None, own=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, directories=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, dst=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, src=None, dst=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, dst=None, mod='644', recursive=False, **kwargs):
#     def do(self):
#     def __init__(self, dst=None, own='root:root', recursive=False, **kwargs):
#     def do(self):
#     def __init__(self, files=None, **kwargs):
#     def pre_process(self):
#     def do(self):
#     def diff(self):
#     def do(self):
#     def __init__(self, src=None, **kwargs):
#     def do(self):
#     def __init__(self, dst=None, replaces=None, appends=None, **kwargs):
#     def pre_process(self):
#     def update(self, data):
#     def do(self):
#     def diff(self, dst=None, **kwargs):
# 
# Path: nuka/tasks/service.py
# class start(Task):
# class restart(Task):
# class reload(Task):
# class stop(Task):
#     def __init__(self, name=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, services=None, **kwargs):
#     def do(self):
#     def __init__(self, services=None, **kwargs):
#     def do(self):
#     def __init__(self, name=None, **kwargs):
#     def do(self):
#     def diff(self):


import nuka
from nuka.tasks import apt
from nuka.tasks import mysql
from nuka.tasks import file
from nuka.tasks import service
    await apt.install(
            debconf={'mysql-server': mysql_password},
            packages=['mysql-server'], update_cache=3600)
    await service.start('mysql')
    await mysql.my_cnf(password=mysql_password)


@nuka.cancel_on_error(mysql_ready)
async def install_master(
        host, mysql_password,
        db_name=None, db_user=None, db_password=None,
        slave=None):
    await install_mysql(host, mysql_password)
    conf = await file.update(
        dst='/etc/mysql/my.cnf',
        replaces=[
            ('^bind-address.+=.+\S+$',
             'bind-address = ' + host.private_ip),
            ('^\#server-id', 'server-id'),
            ('^\#*log_bin', 'log_bin'),
            ('^expire_logs_days.+=.+\S+$', 'expire_logs_days = 1'),
            ('^\#*binlog_do_db.+=.+\S+$', 'binlog_do_db = wp'),
        ],
        appends=[
            ('^binlog_do_db =', 'binlog_format = ROW'),
            ('^binlog_format =', 'transaction-isolation = READ-COMMITTED'),
        ])
    if conf.changed:
        await service.restart('mysql')
    if db_name:

# Path: nuka/tasks/apt.py
# GPG_HEADER = b'-----BEGIN PGP PUBLIC KEY BLOCK-----'
# def apt_watcher(delay, fd):
#     def watcher(task, process):
#     def __init__(self, name=None, src=None, key=None, update=True, **kwargs):
#     def add_key(self, key):
#     def do(self):
#     def diff(self):
#     def __init__(self, cache=None, **kwargs):
#     def do(self):
#     def __init__(self, update_cache=None, **kwargs):
#     def do(self):
#     def __init__(self, packages, **kwargs):
#     def do(self):
#     def __init__(self, packages=None, debconf=None,
#                  debian_frontend='noninteractive', **kwargs):
#     def do(self):
#     def __init__(self, selections=None, **kwargs):
#     def do(self):
#     def __init__(self, packages=None, debconf=None,
#                  debian_frontend='noninteractive', debian_priority=None,
#                  update_cache=None, install_recommends=False, **kwargs):
#     def get_packages_list(self, packages):
#     def do(self):
#     def diff(self):
# class source(Task):
# class update(Task):
# class list(Task):
# class search(Task):
# class upgrade(Task):
# class debconf_set_selections(Task):
# class install(Task):
# 
# Path: nuka/tasks/mysql.py
# class my_cnf(Task):
# class set_root_password(my_cnf):
# class create_db(Task):
# class execute(Task):
#     def __init__(self, password=None, switch_user='root', **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, password=None, **kwargs):
#     def do(self):
#     def __init__(self, name=None, user=None, password=None, **kwargs):
#     def do(self):
#     def __init__(self, sql=None, **kwargs):
#     def do(self):
# 
# Path: nuka/tasks/file.py
# class exists(Task):
# class mkdir(Task):
# class mkdirs(Task):
# class rm(Task):
# class mv(Task):
# class chmod(Task):
# class chown(Task):
# class put(Task):
# class scripts(put):
# class cat(Task):
# class update(Task):
#     def __init__(self, dst=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, dst=None, mod=None, own=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, directories=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, dst=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, src=None, dst=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, dst=None, mod='644', recursive=False, **kwargs):
#     def do(self):
#     def __init__(self, dst=None, own='root:root', recursive=False, **kwargs):
#     def do(self):
#     def __init__(self, files=None, **kwargs):
#     def pre_process(self):
#     def do(self):
#     def diff(self):
#     def do(self):
#     def __init__(self, src=None, **kwargs):
#     def do(self):
#     def __init__(self, dst=None, replaces=None, appends=None, **kwargs):
#     def pre_process(self):
#     def update(self, data):
#     def do(self):
#     def diff(self, dst=None, **kwargs):
# 
# Path: nuka/tasks/service.py
# class start(Task):
# class restart(Task):
# class reload(Task):
# class stop(Task):
#     def __init__(self, name=None, **kwargs):
#     def do(self):
#     def diff(self):
#     def __init__(self, services=None, **kwargs):
#     def do(self):
#     def __init__(self, services=None, **kwargs):
#     def do(self):
#     def __init__(self, name=None, **kwargs):
#     def do(self):
#     def diff(self):


# Path: examples/wordpress/mysql.py
import nuka
from nuka.tasks import apt
from nuka.tasks import mysql
from nuka.tasks import file
from nuka.tasks import service

    await apt.install(
            debconf={'mysql-server': mysql_password},
            packages=['mysql-server'], update_cache=3600)
    await service.start('mysql')
    await mysql.my_cnf(password=mysql_password)


@nuka.cancel_on_error(mysql_ready)
async def install_master(
        host, mysql_password,
        db_name=None, db_user=None, db_password=None,
        slave=None):
    await install_mysql(host, mysql_password)
    conf = await file.update(
        dst='/etc/mysql/my.cnf',
        replaces=[
            ('^bind-address.+=.+\S+$',
             'bind-address = ' + host.private_ip),
            ('^\#server-id', 'server-id'),
            ('^\#*log_bin', 'log_bin'),
            ('^expire_logs_days.+=.+\S+$', 'expire_logs_days = 1'),
            ('^\#*binlog_do_db.+=.+\S+$', 'binlog_do_db = wp'),
        ],
        appends=[
            ('^binlog_do_db =', 'binlog_format = ROW'),
            ('^binlog_format =', 'transaction-isolation = READ-COMMITTED'),
        ])
    if conf.changed:
        await service.restart('mysql')
    if db_name:

        await mysql.create_db(name=db_name, user=db_user, password=db_password)