コード例 #1
0
def install_nginx(username):
    """ installs nginx

        nginx is used for the packaging process.
        the acceptance tests will produce a rpm/deb package.
        that package is then made available on http so that the acceptance
        test node can connect to it as a yub/deb repository and download,
        install the package during the acceptance tests.
    """

    if 'centos' in username:
        yum_install(packages=['nginx'])
        systemd('nginx', start=False, unmask=True)
        systemd('nginx', start=True, unmask=True)
        enable_firewalld_service()
        add_firewalld_port('80/tcp', permanent=True)
    if 'ubuntu' in username:
        sudo('apt-get -y install nginx')
        # systemd('nginx', start=False, unmask=True)
        # systemd('nginx', start=True, unmask=True)
        # enable_firewalld_service()
        # add_firewalld_port('80/tcp', permanent=True)
    # give it some time for the dockerd to restart
    sleep(20)
コード例 #2
0
def bootstrap_jenkins_slave_centos7(instance):
    # ec2 hosts get their ip addresses using dhcp, we need to know the new
    # ip address of our box before we continue our provisioning tasks.
    # we load the state from disk, and store the ip in ec2_host#
    cloud_host = "%s@%s" % (instance.username, instance.ip_address)
    distro = instance.distro
    with settings(host_string=cloud_host,
                  key_filename=instance.key_filename):
        install_os_updates(distribution='centos7')

        # make sure our umask is set to 022
        fix_umask(instance.username)

        # ttys are tricky, lets make sure we don't need them
        disable_requiretty_on_sudoers()

        # when we sudo, we want to keep our original environment variables
        disable_env_reset_on_sudo()

        add_epel_yum_repository()

        install_centos_development_tools()

        # installs a bunch of required packages
        yum_install(packages=centos7_required_packages())

        # installing the source for the centos kernel is a bit of an odd
        # process these days.
        yum_install_from_url(
            "http://vault.centos.org/7.1.1503/updates/Source/SPackages/"
            "kernel-3.10.0-229.11.1.el7.src.rpm",
            "non-available-kernel-src")

        # we want to be running the latest kernel before installing ZFS
        # so, lets reboot and make sure we do.
        with settings(warn_only=True):
            reboot()
        wait_for_ssh(instance.ip_address)

        # install the latest ZFS from testing
        add_zfs_yum_repository()
        yum_install_from_url(
            "http://archive.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm",
            "zfs-release")
        install_zfs_from_testing_repository()

        # note: will reboot the host for us if selinux is disabled
        enable_selinux()
        wait_for_ssh(instance.ip_address)

    # these are likely to happen after a reboot

    with settings(host_string=cloud_host,
                  key_filename=instance.key_filename):
        # brings up the firewall
        enable_firewalld_service()

        # we create a docker group ourselves, as we want to be part
        # of that group when the daemon first starts.
        create_docker_group()
        add_user_to_docker_group(distro)
        install_docker()

        # ubuntu uses dash which causes jenkins jobs to fail
        symlink_sh_to_bash(distro)

        # some flocker acceptance tests fail when we don't have
        # a know_hosts file
        sudo("mkdir -p /root/.ssh")
        sudo("touch /root/.ssh/known_hosts")

        # generate a id_rsa_flocker
        sudo("test -e  $HOME/.ssh/id_rsa_flocker || ssh-keygen -N '' "
             "-f $HOME/.ssh/id_rsa_flocker")

        # and fix perms on /root/.ssh
        sudo("chmod -R 0600 /root/.ssh")

        # TODO: this may not be needed, as packaging is done on a docker img
        install_system_gem('fpm')

        systemd(service='docker', restart=True)
        systemd(service='nginx', start=True, unmask=True)

        # cache some docker images locally to speed up some of our tests
        for docker_image in local_docker_images():
            cache_docker_image_locally(docker_image)

        # centos has a fairly old git, so we install the latest version
        # in every box.
        install_recent_git_from_source()
        add_usr_local_bin_to_path()

        # to use wheels, we want the latest pip
        update_system_pip_to_latest_pip()

        # cache the latest python modules and dependencies in the local
        # user cache
        git_clone('https://github.com/ClusterHQ/flocker.git', 'flocker')
        with cd('flocker'):
            run('pip install --quiet --user .')
            run('pip install --quiet '
                '--user --process-dependency-links ".[dev]"')
            run('pip install --quiet --user python-subunit junitxml')

        # nginx is used during the acceptance tests, the VM built by
        # flocker provision will connect to the jenkins slave on p 80
        # and retrieve the just generated rpm/deb file
        install_nginx(instance.username)

        # /etc/slave_config is used by the jenkins_slave plugin to
        # transfer files from the master to the slave
        create_etc_slave_config()

        # installs python-pypy onto /opt/python-pypy/2.6.1 and symlinks it
        # to /usr/local/bin/pypy
        install_python_pypy('2.6.1')