Esempio n. 1
0
def enable_maintenance():
    """Enables a maintenance page and serves a 503"""
    """Only to be run on loadbalancers"""
    if not fabric.contrib.files.exists(maintenance_config):
        abort("Sorry this task can only currently be run on loadbalancers")
    puppet.disable("Maintenance mode enabled")
    sudo("echo 'set $maintenance 1;' > {0}".format(maintenance_config))
    sudo('service nginx reload')
def failover_to_rubygems():
    """Change bundler to use rubygems.org for gems rather than gemstash"""
    bundler_config = get_bundler_config()
    puppet.disable('Fabric failover_to_rubygems invoked')
    # Overwrite the bundler config with an empty file to force failover to default
    # Use an empty file rather than rm to avoid running rm as sudo.
    sudo('echo "" > {0}'.format(bundler_config))
    print('Disabled puppet and overwritten the bundler config file.')
    print('Run "bundler.revert_mirror" to start using gemstash again.')
Esempio n. 3
0
def failover_to_rubygems():
    """Change bundler to use rubygems.org for gems rather than gemstash"""
    bundler_config = get_bundler_config()
    puppet.disable('Fabric failover_to_rubygems invoked')
    # Overwrite the bundler config with an empty file to force failover to default
    # Use an empty file rather than rm to avoid running rm as sudo.
    sudo('echo "" > {0}'.format(bundler_config))
    print('Disabled puppet and overwritten the bundler config file.')
    print('Run "bundler.revert_mirror" to start using gemstash again.')
Esempio n. 4
0
def disable_logit():
    """Disable filebeat so we don't send data to Logit.io"""
    with hide('everything'):
        locked = sudo(
            'test -f /var/lib/puppet/state/agent_disabled.lock && echo DISABLED || echo ENABLED'
        )

    if locked == "ENABLED":
        puppet.disable("Disable sending to logit")

    sudo("service filebeat stop")
def enable_maintenance(*app_list):
    """Enables a maintenance page for publishers and serves a 503"""
    """Only to be run on loadbalancers"""
    if not fabric.contrib.files.exists(maintenance_config):
        abort("Sorry this task can only currently be run on loadbalancers")
    puppet.disable("Maintenance mode enabled")
    env_url_post = fabric.state.env.gateway.lstrip("jumpbox.")
    app_list = list(app_list)
    if not valid_apps.issuperset(app_list):
        print("{} are not valid apps for this maintenance.".format(
            list(set(app_list).difference(valid_apps))))
        exit(1)
    for app in app_list:
        app_hostname = "{}.{}".format(app, env_url_post)
        app_config_file = "/etc/nginx/sites-enabled/{}".format(app_hostname)
        maintenance_setting = "set $maintenance 1;"
        fabric.contrib.files.sed(app_config_file,
                                 "include includes/maintenance.conf;",
                                 maintenance_setting,
                                 use_sudo=True,
                                 backup=".maint-bak")
    with cd('/etc/nginx/sites-enabled/'):
        sudo('rm -f *.maint-bak')
    sudo('service nginx reload')
Esempio n. 6
0
def fail_to_mirror():
    """Fails the site to the mirror by stopping nginx on the cache nodes"""
    puppet.disable("Fabric fail_to_mirror task invoked")
    execute(nginx.kill)
    print('Disabled Puppet and switched off Nginx.')
    print('Run `incident.recover_origin` to start serving from origin again.')
Esempio n. 7
0
def fail_to_mirror():
    """Fails the site to the mirror by stopping nginx on the cache nodes"""
    puppet.disable("Fabric fail_to_mirror task invoked")
    execute(nginx.kill)
    print('Disabled Puppet and switched off Nginx.')
    print('Run `incident.recover_origin` to start serving from origin again.')
Esempio n. 8
0
def fail_to_mirror():
    """Fails the site to the mirror"""
    puppet.disable()
    nginx.disable_vhost("www.gov.uk")
    nginx.hello_it()
    print("Disabled Puppet and www.gov.uk vhost, remember to re-enable and re-run puppet to restore previous state")