Automating OpenStack installations using Ansible – running Playbooks

In this recipe, we simply run a series of Ansible Playbooks that lay down the infrastructure needed on top of our six Ubuntu 14.04 LTS hosts, and then install all of the software required to run a highly available OpenStack installation.

Ansible uses SSH and Python to execute the Playbooks that describe how to install and configure software on distributed systems. Its lightweight design with very few dependencies makes it perfect to install OpenStack across our many Ubuntu hosts.

Getting ready

It is important that the previous two recipes, Automating OpenStack installations using Ansible – host configuration and Automating OpenStack installations using Ansible – Playbook configuration, have been followed, that all the configured networks are working as expected, and that the relevant configuration files are edited to suit the upcoming installation. If not, please log in to the Logging host where the Ansible OpenStack Deployment has been configured.

How to do it...

Now that we have a set of configuration files in /etc/openstack_deploy that our Ansible Playbooks will look for and understand, we can begin the installation of OpenStack by following these steps:

  1. First, we need to ensure that Ansible is installed on our host that we're using to run the installation from. In this case, this is the Logging host. This can be achieved by running the following command:
    cd /opt/os-ansible-deployment
    scripts/bootstrap-ansible.sh
    
  2. Once the installation has finished, it will have produced a wrapper script called openstack-ansible that we will use to run the Playbooks. The first Playbook to run is the setup-hosts.yml file. This is run by executing the following commands:
    cd /opt/os-ansible-deployment/playbooks
    openstack-ansible setup-hosts.yml
    

    We will get an output that will be familiar to anyone running Ansible and give verbose information during the running of the Playbooks.

    Tip

    If the Playbook fails, as denoted by the final message with the states of the changes, we can re-run the Playbooks and target only the failed portions by executing the following commands:

    openstack-ansible setup-hosts.yml 
        --limit @/root/setup-hosts.retry
  3. If the output shows all OK messages in green, with no failed or unreachable hosts, then we can proceed to run the next set of Playbooks. As we're running HA Proxy in this recipe, we run this next by executing the following. Note that if you are installing OpenStack sitting behind a Load Balancer such as an F5, this must be configured separately at this stage:
    openstack-ansible haproxy-install.yml
    

    Tip

    If the Playbook fails as denoted by the final message with the states of the changes, we can re-run the Playbook and targeting only the failed portions by executing the following commands:

    openstack-ansible haproxy-install.yml 
        --limit @/root/haproxy-install.retry
  4. If the output shows all OK messages in green, with no failed or unreachable hosts, then we can proceed to run the next set of Playbooks that runs the infrastructure services required to support OpenStack. This Playbook configures the many LXC containers used in this installation and the Galera and RabbitMQ services that support OpenStack. To execute this Playbook, run the following command. Note that this usually takes quite a bit of time to run, so be patient:
    openstack-ansible setup-infrastructure.yml
    

    Tip

    If the Playbook fails, as denoted by the final message with the states of the changes, we can re-run the Playbook and target only the failed portions by executing the following command:

    openstack-ansible setup-infrastructure.yml 
        --limit @/root/setup-infrastructure.retry
  5. If the output is all green and OK, we can now carry on and install all of the OpenStack services by simply executing the following command. This step takes a while:
    openstack-ansible setup-openstack.yml
    

    Tip

    If the Playbook fails, as denoted by the final message with the states of the changes, we can re-run the Playbook and target only the failed portions by executing the following command:

    openstack-ansible setup-openstack.yml 
        --limit @/root/setup-openstack.retry
  6. Congratulations! We have completed the installation of OpenStack using Ansible. To log in to the environment either use Horizon, by pointing the browser to the Load Balancer address, or use ssh command to connect to a utility container as follows:
    grep utility /etc/hosts
    

    Identify one of them to connect using the ssh command to the following:

    ssh controller-01_utility_container-88105269
    

    Source in the OpenStack credentials and use the environment as usual:

    . openrc
    

How it works...

Ansible is a very powerful yet lightweight system that runs Playbooks over SSH to install and configure software. It is perfect for installing OpenStack that lays down software across the many number of nodes.

A number of Playbooks are run, and they are listed as follows:

  • setup-hosts.yml: This installs and configures the LXC containers across our nodes, which will be the targets for the installation of the various OpenStack services in the environment.
  • haproxy-install.yml: This allows us to use HA Proxy for our installation. As we are running a set of three controllers, we need a Load Balancer to allow the services to communicate correctly in our environment.
  • setup-infrastructure.yml: This installs all the ancillary services such, as MariaDB, Galera, memcached, and RabbitMQ.
  • setup-openstack.yml: This installs all the OpenStack services required to give a complete, production-ready installation on our environment.

Should any of the Playbooks fail, a shortcut to fix just the necessary parts can be achieved by specifying --limit @/root/{playbook}.retry (omitting the .yml extension). Ansible is very verbose in its output and will inform you when this is possible, as shown here:

How it works...

Tip

This environment has been configured so that Glance uses the local filesystem for the uploaded images to be used in OpenStack. As we have installed a cluster of three Glance image servers, it is assumed that images will be uploaded to Glance using the --location <IMAGE_URL> flag. This flag tells Glance to fetch the image from the IMAGE_URL provided rather than store the image locally. Adjust the /etc/openstack_deploy/user_variables.yml file as described in the previous recipe to choose a different storage option for Glance to suit your environment.

There's more...

This installation involved a number of Playbooks that configured our host, installed extra services, and then installed OpenStack. There is a wrapper script that can be used that covers all of these steps in one command. This can be achieved by running the following command instead:

cd /opt/os-ansible-deployment
scripts/run-playbooks.sh

Note that by splitting up the installation, we can fix specific Playbook issues as well as having a chance for HA Proxy to be configured correctly. It is therefore prudent to use the preceding Playbook when setting up a test environment on a single host.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset