Installing and configuring Ansible for OpenStack

Ansible has relatively few prerequisites that are not installed on most Linux- and macOS-based systems. However, there are a few steps to follow before we can use Ansible for managing our OpenStack environment.

Getting ready

Ensure that you are logged on to a correctly configured OpenStack client and can access the OpenStack environment. Refer to Chapter 2, The OpenStack Client, for details of setting up your environment to use OpenStack.

The version of Ansible 2.x requires Python 2.6 or 2.7. Most modern Linux distributions and macOS/OS X have this already installed. If you were able to successfully execute the openstack commands as described in Chapter 2, The OpenStack Client, then you're good to go here.

You may need to install Shade. Shade is a simple client library for interacting with OpenStack clouds. Red Hat and CentOS environments don't have this installed by default. Install it with the following command:

sudo pip install shade

Note

Be aware that Shade may pull in other dependencies that may break your environment. It is suggested that you use a virtual environment (venv) to avoid this issue.

How to do it...

As we're performing this on our client machine, ensure that you have the necessary permissions to install software. When ready, carry out the following steps depending on your chosen operating system.

Ubuntu

For Ubuntu, we can use the Ansible PPA as follows:

  1. First, ensure that we can add PPA (Personal Package Archives) by installing the following tool:
    sudo apt-get install software-properties-common
    
  2. Next, we will add the PPA:
    sudo apt-add-repository ppa:ansible/ansible
    
  3. Finally, we will run the installation:
    sudo apt-get update
    sudo apt-get install ansible
    

macOS/OS X (and for those wanting to use pip)

For macOS, we can use pip as follows:

  1. Ensure that pip is available:
    sudo easy_install pip
    
  2. Next, use pip to install Ansible:
    sudo pip install ansible
    

Verifying the installation

To verify the installation, issue the following command:

ansible --version

This should produce an output like the following:

Verifying the installation

How it works...

In order for us to be able to use Ansible to manage our OpenStack environment, we must ensure that we have a good working Ansible set up. The preceding steps merely helped us install Ansible onto our client using the tools available for that operating system.

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

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