示例#1
0
def core():
    """
    Require the docker core installation.

    Example::

        from fabtools import require

        require.docker.core()

    """

    from fabtools.require.deb import package as require_deb_package
    from fabtools.require.rpm import package as require_rpm_package

    family = distrib_family()

    # Check if sudo command exists
    if not files.exists('/usr/bin/sudo'):
        raise Exception(
            "Please install the sudo package and execute adduser %s sudo" %
            env.user)

    if not files.exists('/usr/bin/docker'):
        if family == 'debian':
            require_deb_package('curl')
        elif family == 'redhat':
            require_rpm_package('curl')
        else:
            raise UnsupportedFamily(supported=['debian', 'redhat'])

        # Download docker installation
        run_as_root('curl -sSL https://get.docker.com/ | sh')
示例#2
0
def  core():
    """
    Require the docker core installation.

    Example::

        from fabtools import require

        require.docker.core()

    """

    from fabtools.require.deb import package as require_deb_package
    from fabtools.require.rpm import package as require_rpm_package

    family = distrib_family()

    # Check if sudo command exists
    if not files.exists('/usr/bin/sudo'):
        raise Exception("Please install the sudo package and execute adduser %s sudo" % env.user)


    if not files.exists('/usr/bin/docker'):
        if family == 'debian':
            require_deb_package('curl')
        elif family == 'redhat':
            require_rpm_package('curl')
        else:
            raise UnsupportedFamily(supported=['debian', 'redhat'])

        # Download docker installation
        run_as_root('curl -sSL https://get.docker.com/ | sh')
示例#3
0
文件: api.py 项目: Hoedic/fab_taxi
def install_swagger_ui():
    with cd('~'):
        if not files.exists('APITaxi_swagger'):
            git.clone('https://github.com/openmaraude/APITaxi_swagger')
        git.checkout('APITaxi_swagger')
        git.pull('APITaxi_swagger')
        return path.join(run('pwd'), 'APITaxi_swagger')
示例#4
0
def setup_tilestream():
    """Set up tile stream - see https://github.com/mapbox/tilestream.

    This one deserves a little explanation:

    Tilestream is a nodejs application. Node seems to be pretty unparticular
    about maintaining api compatibility between releases so if you grab one
    from e.g. apt, chances are it won't work with tilestream.

    To address this, we use the nodeenv virtualisation environment (somewhat
    equivalent to using python virtualenv) to ensure that we have the
    expected version of tilestream. e.g.::

        nodeenv env --node=0.8.15
    """
    setup_env()
    require.deb.package('curl')
    require.deb.package('build-essential')
    require.deb.package('libssl-dev')
    require.deb.package('libsqlite3-0')
    require.deb.package('libsqlite3-dev')
    require.deb.package('git-core')
    require.deb.package('nodejs nodejs-dev npm')
    require.deb.package('python-pip')

    sudo('pip install nodeenv')

    dev_dir = '/home/%s/dev/javascript' % env.fg.user
    fastprint('making directory %s' % dev_dir)
    require.directory(dev_dir)

    tile_stream_dir = os.path.join(dev_dir, 'tilestream')
    fastprint('checkout out tilestream to %s' % tile_stream_dir)

    if not exists(tile_stream_dir):
        with cd(dev_dir):
            run('git clone http://github.com/mapbox/tilestream.git')

    with cd(tile_stream_dir):
        if not exists(os.path.join(tile_stream_dir, 'env')):
            run('nodeenv env --node=0.8.15')
        # If doing this interactively from a shell you would first do:
        # . env/bin/activate
        # npm install
        # From our scripted environment (where we cant activate the venv):
        run('env/bin/npm install')
示例#5
0
def setup_tilestream():
    """Set up tile stream - see https://github.com/mapbox/tilestream.

    This one deserves a little explanation:

    Tilestream is a nodejs application. Node seems to be pretty unparticular
    about maintaining api compatibility between releases so if you grab one
    from e.g. apt, chances are it won't work with tilestream.

    To address this, we use the nodeenv virtualisation environment (somewhat
    equivalent to using python virtualenv) to ensure that we have the
    expected version of tilestream. e.g.::

        nodeenv env --node=0.8.15
    """
    setup_env()
    require.deb.package('curl')
    require.deb.package('build-essential')
    require.deb.package('libssl-dev')
    require.deb.package('libsqlite3-0')
    require.deb.package('libsqlite3-dev')
    require.deb.package('git-core')
    require.deb.package('nodejs nodejs-dev npm')
    require.deb.package('python-pip')

    sudo('pip install nodeenv')

    dev_dir = '/home/%s/dev/javascript' % env.fg.user
    fastprint('making directory %s' % dev_dir)
    require.directory(dev_dir)

    tile_stream_dir = os.path.join(dev_dir, 'tilestream')
    fastprint('checkout out tilestream to %s' % tile_stream_dir)

    if not exists(tile_stream_dir):
        with cd(dev_dir):
            run('git clone http://github.com/mapbox/tilestream.git')

    with cd(tile_stream_dir):
        if not exists(os.path.join(tile_stream_dir, 'env')):
            run('nodeenv env --node=0.8.15')
        # If doing this interactively from a shell you would first do:
        # . env/bin/activate
        # npm install
        # From our scripted environment (where we cant activate the venv):
        run('env/bin/npm install')
示例#6
0
def require_docker():
    """
    Install a docker core
    """

    # Install package
    if not files.exists('/usr/bin/docker'):
        require.deb.update_index()
        require.docker.core()

    # Requirement platform
    require.deb.packages(['openvswitch-switch'])

    # Group user
    if env.user != 'root':
        require.user(env.user, group='docker')

    require.service.started('docker')
示例#7
0
def uninstall(app, d):
    if d.exists() and d.name == 'systemd':
        for unit in d.iterdir():
            delete = ['/usr/bin/{0}-{1}'.format(app.name, unit.name)]
            enable = 'service'
            for name in ['service', 'timer']:
                if name == 'timer':
                    enable = name
                delete.append('/etc/systemd/system/{0}-{1}.{2}'.format(
                    app.name, unit.name, name))
            sudo('systemctl stop {0}-{1}.{2}'.format(app.name, unit.name,
                                                     enable))
            sudo('systemctl disable {0}-{1}.{2}'.format(
                app.name, unit.name, enable))
            for p in delete:
                if files.exists(p):
                    sudo('rm {0}'.format(p))
        sudo('systemctl daemon-reload')
        sudo('systemctl reset-failed')
示例#8
0
def require_docker():
    """
    Install a docker core
    """

    # Install package
    if not files.exists('/usr/bin/docker'):
        require.deb.update_index()
        require.docker.core()

    # Requirement platform
    require.deb.packages([
        'openvswitch-switch'
    ])

    # Group user
    if env.user != 'root':
        require.user(env.user, group='docker')

    require.service.started('docker')