def install_deb_java_jdk(): add_apt_sources(True, 'deb http://archive.canonical.com/ lucid partner') sudo("sh -c 'echo sun-java6-jdk shared/accepted-sun-dlj-v1-1 select" + \ " true " + \ "| /usr/bin/debconf-set-selections';") install('sun-java6-jdk')
def install_deb(): if not check_cmd('cassandra'): add_apt_sources(False, 'deb http://www.apache.org/dist/cassandra/debian 08x main', 'deb-src http://www.apache.org/dist/cassandra/debian 08x main') run('gpg --keyserver pgpkeys.mit.edu --recv-keys F758CE318D77295D') sudo('apt-key add ~/.gnupg/pubring.gpg') sudo('apt-get update') install('cassandra')
def test_pkg(): cmd_name = 'mp3blaster' pkg_name = 'mp3blaster' if core.check_pkg(pkg_name): core.uninstall(pkg_name) ok(core.pkg()) != None ok(core.check_pkg(pkg_name)) == False ok(core.check_cmd(cmd_name)) == False core.install(pkg_name) ok(core.check_pkg(pkg_name)) == True ok(core.check_cmd(cmd_name)) == True core.uninstall(pkg_name) ok(core.check_pkg(pkg_name)) == False ok(core.check_cmd(cmd_name)) == False
def install_supervisord(): if not check_cmd('supervisorctl'): if not check_cmd('pip'): install('python-pip') pip('supervisor') sudo('echo_supervisord_conf > ' + supervisord_config) put(open(os.path.join(sensor_source, 'supervisor')), '/etc/init.d/supervisor', use_sudo=True) sudo('chmod a+x /etc/init.d/supervisor') sudo('ln -s /etc/init.d/supervisor /etc/rc2.d/S20supervisor') sudo('ln -s /etc/init.d/supervisor /etc/rc3.d/S20supervisor') sudo('ln -s /etc/init.d/supervisor /etc/rc4.d/S20supervisor') sudo('ln -s /etc/init.d/supervisor /etc/rc5.d/S20supervisor') sudo('ln -s /etc/init.d/supervisor /etc/rc6.d/K20supervisor') sudo('/etc/init.d/supervisor start')
def python_venv_init(py_ver, path): install("python=={}".format(py_ver)) install("python-pip") pip('virtualenv') run('virtualenv --no-site-packages {}'.format(path))
def basic(): set_apt_proxy('192.168.122.1', ) install('gcc') install('python-pip') #install_supervisord() allow_all_sudo_no_passwd()
def install_nova(ip, net, net_prefix, lvm_dev, ext_network, proj_name, nova_adm='ubuntu', dbpasswd='nova', compute_backend='lxc'): install('bridge-utils,postgresql,python-psycopg2') replace_in_file("/etc/postgresql/9.1/main/postgresql.conf", "#listen_addresses\s+=\s+'localhost'(.*)", r"listen_addresses = '*'\1", use_sudo=True) pg_hba = '/etc/postgresql/9.1/main/pg_hba.conf' add = "host all all 0.0.0.0/0 md5" sudo("chmod a+rw " + pg_hba) try: append(pg_hba, add) finally: sudo("chmod 640 " + pg_hba) sudo("/etc/init.d/postgresql restart") install('glance') cmd = "CREATE user glancedbadmin;\n" + \ "ALTER user glancedbadmin with password '{0}';\n" + \ 'CREATE DATABASE glance;\n' + \ 'GRANT ALL PRIVILEGES ON database glance TO glancedbadmin;\n' psql(cmd.format(dbpasswd)) replace_in_file("/etc/glance/glance-registry.conf", 'sql_connection = .*?$', 'sql_connection = postgresql://glancedbadmin:{0}@{1}/glance'\ .format(dbpasswd,ip), use_sudo=True) sudo('restart glance-registry') install('rabbitmq-server,nova-common,nova-doc,python-nova,nova-api,' + \ 'nova-network,nova-volume,nova-objectstore,nova-scheduler,' + \ 'nova-compute,euca2ools,unzip,nova-compute-' + compute_backend) cmd = 'CREATE user novadbadmin;\n' + \ "ALTER user novadbadmin with password '{0}';\n" + \ 'CREATE DATABASE nova;\n' + \ 'GRANT ALL PRIVILEGES ON database nova TO novadbadmin;\n' psql(cmd.format(dbpasswd)) cfg = nova_config.format(ip, net, '8', dbpasswd, net_prefix) put_rf('/etc/nova/nova.conf', cfg , use_sudo=True) use_lvm = False if use_lvm: install('iscsitarget,iscsitarget-dkms') sudo("sed -i 's/false/true/g' /etc/default/iscsitarget") sudo("service iscsitarget restart") sudo("pvcreate " + lvm_dev) sudo("vgcreate nova-volumes " + lvm_dev) sudo("chown -R root:nova /etc/nova") sudo("chmod 644 /etc/nova/nova.conf") all_nova_services = ('libvirt-bin,nova-network,nova-compute,nova-api,' + \ 'nova-objectstore,nova-scheduler,' + \ 'glance-api,glance-registry,nova-volume').split(',') for service in all_nova_services: upstart_restart(service) sudo('nova-manage db sync') sudo('nova-manage network create private {0} 1 255'.format(net)) sudo('nova-manage floating create --ip_range=' + ext_network) sudo('nova-manage user admin novaadmin') sudo('nova-manage project create {0} novaadmin'.format(proj_name)) for service in all_nova_services: upstart_restart(service) sudo('mkdir -p /home/{0}/creds'.format(nova_adm)) sudo('nova-manage project zipfile proj novaadmin ' + \ '/home/{0}/creds/novacreds.zip'.format(nova_adm)) with cd('/home/{0}/creds'.format(nova_adm)): sudo('unzip novacreds.zip') sudo('chown {0}:{0} /home/{0}/creds -R'.format(nova_adm)) res = sudo('nova-manage user exports novaadmin') EC2_ACCESS_KEY = None EC2_SECRET_KEY = None for string in str(res).split('\n'): string = string.strip() if string.startswith('export EC2_ACCESS_KEY='): EC2_ACCESS_KEY = string[len('export EC2_ACCESS_KEY='):] elif string.startswith('export EC2_SECRET_KEY='): EC2_SECRET_KEY = string[len('export EC2_SECRET_KEY='):] replace_in_file('/home/{0}/creds/novarc'.format(nova_adm), 'export EC2_ACCESS_KEY="novaadmin:proj"'.format(proj_name), 'export EC2_ACCESS_KEY="{0}:{1}"'.format(EC2_ACCESS_KEY, proj_name)) replace_in_file('/home/{0}/creds/novarc'.format(nova_adm), 'export NOVA_PROJECT_ID="proj"', 'export NOVA_PROJECT_ID="{0}"'.format(proj_name)) return
def install_swift(): packages='swift,swift-proxy,memcached,swift-account,swift-container,' + \ 'swift-object,xfsprogs,curl' install(packages)