def download_and_install(url_prefix, packages): def one(package): run('curl -OL {url_prefix}{package}'.format(url_prefix=url_prefix, package=package)) sudo('dpkg -i {package}'.format(package=package)) with cd(get_tempdir_fab()): return tuple(imap(one, packages))
def install(version='v2.3.7', *args, **kwargs): command = 'etcd' if cmd_avail(command): installed_version = (lambda s: s[s.rfind(' ') + 1:])(run('etcd --version | head -n 1', quiet=True)) if version[1:] == installed_version: local('echo {command} {version} is already installed'.format(command=command, version=version)) return tempdir = get_tempdir_fab(run_command=run) install_dir = '{tempdir}/{version}/{epoch}'.format( tempdir=tempdir, version=version, epoch=run('date +%s', quiet=True) ) run('mkdir -p {install_dir}'.format(install_dir=install_dir)) ubuntu_install_curl() with cd(install_dir): run( 'curl -OL ' 'https://github.com/coreos/etcd/releases/download/{version}/etcd-{version}-linux-amd64.tar.gz'.format( version=version ) ) run('tar xf etcd-{version}-linux-amd64.tar.gz'.format(version=version)) run('sudo mv etcd-{version}-linux-amd64/etcd /usr/local/bin'.format(version=version)) run('sudo mv etcd-{version}-linux-amd64/etcdctl /usr/local/bin'.format(version=version)) run('logout') # Need to get stuff from /etc/environment on next run