Example #1
0
def modconfb(c, names=None):
    "modconf with backup"
    if names is None:
        return
    names = names.split(',')
    for conf in names:
        shared.mod_conf(c, os.path.join(FROM, conf), A_AVAIL, backup=True)
Example #2
0
def modconfa(c, names=None):
    "modconf with append (and backup)"
    if names is None:
        return
    names = names.split(',')
    for conf in names:
        shared.mod_conf(c, os.path.join(FROM, conf), A_AVAIL, append=True)
Example #3
0
def modconf(c, names=None):
    "deploy modifications for Apache configuration file(s), replace version"
    if names is None:
        return
    names = names.split(',')
    for conf in names:
        shared.mod_conf(c, os.path.join(FROM, conf), A_AVAIL)
Example #4
0
def newconf(c, names=None):
    """shortcut to define and enable a new Nginx config in one go
    """
    names = names.split(',') if names else []
    for conf in names:
        shared.mod_conf(c, os.path.join(FROM, conf.strip()), AVAIL)
        shared.add_conf(c, conf.strip(), AVAIL, ENABL)
Example #5
0
def modconfa(c, names=None):
    "modconf: backup & append version"
    names = names.split(',') if names else []
    for conf in names:
        shared.mod_conf(c,
                        os.path.join(FROM, conf.strip()),
                        AVAIL,
                        append=True)
Example #6
0
def test_mod_conf(monkeypatch, capsys):
    class MockDatetime:
        def today(*args):
            return MockDatetime()
        def strftime(*args):
            return 'today'
    def mock_run(self, *args):
        print('execute in {}'.format(self.cwd))
        print(*args)
    monkeypatch.setattr(MockContext, 'run', mock_run)
    c = MockContext()
    tasks_shared.mod_conf(c, 'from/file', 'to')
    assert capsys.readouterr().out == 'execute in from\nsudo cp file to\n'
    tasks_shared.mod_conf(c, 'from/file', 'to', needs_sudo=False)
    assert capsys.readouterr().out == 'execute in from\n cp file to\n'
    monkeypatch.setattr(tasks_shared.datetime, 'datetime', MockDatetime)
    tasks_shared.mod_conf(c, 'from/file', 'to', backup=True)
    assert capsys.readouterr().out == ('execute in from\nmkdir -m 777 backup\n'
                                       'execute in from\ncp to/file backup/file-today\n'
                                       'execute in from\nsudo cp file to\n')
    tasks_shared.mod_conf(c, 'from/file', 'to', append=True)
    assert capsys.readouterr().out == ('execute in from\nmkdir -m 777 backup\n'
                                       'execute in from\ncp to/file backup/file-today\n'
                                       'execute in from\ncp file file~~\n'
                                       'execute in from\ncat backup/file-today file > file~~~\n'
                                       'execute in from\nmv -f file~~~ file\n'
                                       'execute in from\nsudo cp file to\n'
                                       'execute in from\nmv -f file~~ file\n')
Example #7
0
def modconfa(c, names=None):
    "modconf: backup & append version"
    names = names.split(',') if names else []
    for conf in names:
        path, dest, sudo = get_parms(conf)
        shared.mod_conf(c, path, dest, needs_sudo=sudo, append=True)
Example #8
0
def modconf(c, names=None):
    "deploy modifications for configuration file(s); replace version"
    names = names.split(',') if names else []
    for conf in names:
        path, dest, sudo = get_parms(conf)
        shared.mod_conf(c, path, dest, needs_sudo=sudo)
Example #9
0
def modconf(c, names=None):
    "deploy modifications for Nginx configuration file(s); replace version"
    names = names.split(',') if names else []
    for conf in names:
        shared.mod_conf(c, os.path.join(FROM, conf.strip()), AVAIL)