def install_oracle_jdk(): """Install the official oracle jdk.""" fastprint(yellow('Setting up oracle java on host: %s' % env.host)) require_ppa('ppa:webupd8team/java') apt_get_update() require_package('software-properties-common') sudo('echo oracle-java7-installer shared/accepted-oracle-license-v1-1 ' 'select true | debconf-set-selections') require_package('oracle-java7-installer') fastprint(green('Installation of oracle java completed ok!'))
def install_oracle_jdk(): """Install the official oracle jdk.""" fastprint(yellow('Setting up oracle java on host: %s' % env.host)) require_ppa('ppa:webupd8team/java') apt_get_update() require_package('software-properties-common') sudo( 'echo oracle-java7-installer shared/accepted-oracle-license-v1-1 ' 'select true | debconf-set-selections') require_package('oracle-java7-installer') fastprint(green('Installation of oracle java completed ok!'))
def setup_docker(force=False): """Setup docker on the target host. :param force: Whether to continue with installation even if docker already appears to be installed. Defaults to False. :type force: bool """ fastprint(yellow('Setting up docker on host: %s\n' % env.host)) if is_installed('lxc-docker'): fastprint( green( 'This system already appears to have docker installed on it\n') ) else: version = run('uname -r') if '3.2' in version: # LTS 3.2 version is too old so we install a backported one # see http://docs.docker.io/en/latest/installation/ubuntulinux/ # #ubuntu-precise-12-04-lts-64-bit fastprint(red('Upgrading kernel to 3.8!\n')) response = prompt('Do you wish to continue? y/n :') if response != 'y': fastprint(red('Docker install aborted by user.\n')) return fastprint(blue('Ok upgrading kernel.')) require_packages([ 'linux-image-generic-lts-raring', 'linux-headers-generic-lts-raring' ]) fastprint(red('\nWe need to reboot the system now!\n')) response = prompt('Do you wish to continue? y/n :') if response is not None: reboot() else: require_package('linux-image-extra-%s' % version) require_ppa('ppa:dotcloud/lxc-docker') apt_get_update() require_packages(['software-properties-common', 'lxc-docker']) # Ensure ufw forwards traffic. # http://docs.docker.io/en/latest/installation/ubuntulinux/#ufw sed('/etc/default/ufw', 'DEFAULT_FORWARD_POLICY="DROP"', 'DEFAULT_FORWARD_POLICY="ACCEPT"', use_sudo=False) setup_docker_image() setup_docker_user()
def setup_docker(force=False): """Setup docker on the target host. :param force: Whether to continue with installation even if docker already appears to be installed. Defaults to False. :type force: bool """ fastprint(yellow('Setting up docker on host: %s\n' % env.host)) if is_installed('lxc-docker'): fastprint(green( 'This system already appears to have docker installed on it\n')) else: version = run('uname -r') if '3.2' in version: # LTS 3.2 version is too old so we install a backported one # see http://docs.docker.io/en/latest/installation/ubuntulinux/ # #ubuntu-precise-12-04-lts-64-bit fastprint(red('Upgrading kernel to 3.8!\n')) response = prompt('Do you wish to continue? y/n :') if response != 'y': fastprint(red('Docker install aborted by user.\n')) return fastprint(blue('Ok upgrading kernel.')) require_packages([ 'linux-image-generic-lts-raring', 'linux-headers-generic-lts-raring']) fastprint(red('\nWe need to reboot the system now!\n')) response = prompt('Do you wish to continue? y/n :') if response is not None: reboot() else: require_package('linux-image-extra-%s' % version) require_ppa('ppa:dotcloud/lxc-docker') apt_get_update() require_packages([ 'software-properties-common', 'lxc-docker']) # Ensure ufw forwards traffic. # http://docs.docker.io/en/latest/installation/ubuntulinux/#ufw sed( '/etc/default/ufw', 'DEFAULT_FORWARD_POLICY="DROP"', 'DEFAULT_FORWARD_POLICY="ACCEPT"', use_sudo=False) setup_docker_image() setup_docker_user()
def process(name, **kwargs): """ Require a supervisor process to be running. Keyword arguments will be used to build the program configuration file. Some useful arguments are: - ``command``: complete command including arguments (**required**) - ``directory``: absolute path to the working directory - ``user``: run the process as this user - ``stdout_logfile``: absolute path to the log file You should refer to the `supervisor documentation`_ for the complete list of allowed arguments. .. note:: the default values for the following arguments differs from the ``supervisor`` defaults: - ``autorestart``: defaults to ``true`` - ``redirect_stderr``: defaults to ``true`` Example:: from fabtools import require require.supervisor.process('myapp', command='/path/to/venv/bin/myapp --config production.ini --someflag', directory='/path/to/working/dir', user='******', stdout_logfile='/path/to/logs/myapp.log', ) .. _supervisor documentation: http://supervisord.org/configuration.html#program-x-section-values """ from fabtools.require.deb import package as require_package from fabtools.require import file as require_file from fabtools.require.service import started as require_started require_package('supervisor') require_started('supervisor') # Set default parameters params = {} params.update(kwargs) params.setdefault('autorestart', 'true') params.setdefault('redirect_stderr', 'true') # Build config file from parameters lines = [] lines.append('[program:%(name)s]' % locals()) for key, value in sorted(params.items()): lines.append("%s=%s" % (key, value)) # Upload config file filename = '/etc/supervisor/conf.d/%(name)s.conf' % locals() with watch(filename, callback=update_config, use_sudo=True): require_file(filename, contents='\n'.join(lines), use_sudo=True) # Start the process if needed if process_status(name) == 'STOPPED': start_process(name)