Chapter 4. Deploying Instance HA
The following sections describe how to use the Ansible automation framework to enable Instance HA. For more information about Ansible, see Ansible Documentation.
4.1. Creating the Required Ansible Configuration Files
Before you enable Instance HA through Ansible, you need to create an inventory file and an SSH arguments file. These files pass the Ansible variables that you will need to prepare the undercloud for Instance HA, as described in Section 4.2, “Preparing the Undercloud”.
Inventory File
The inventory file lists the different target hosts for the ansible playbooks. It is divided into two sections:
List of all nodes by name, along with the hostname, username, and private key file that Ansible should use for each playbook command. For example:
overcloud-controller-0 ansible_host=overcloud-controller-0 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa
-
List of headings that represent node types, where each type lists the nodes that belong to it. The node types are
compute,undercloud,overcloud, orcontroller.
The following procedure describes how to set up the inventory file.
Generate a complete inventory of all nodes in the undercloud and the overcloud with the following command:
stack@director $ tripleo-ansible-inventory --listThis command generates a detailed and updated inventory in JSON format. For more information, see Running Ansible Automation.
Create the inventory file with the name hosts in /home/stack/. The following example shows the required format to use when creating the file:
undercloud ansible_host=undercloud ansible_user=stack ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-compute-1 ansible_host=overcloud-compute-1 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-compute-0 ansible_host=overcloud-compute-0 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-controller-2 ansible_host=overcloud-controller-2 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-controller-1 ansible_host=overcloud-controller-1 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa overcloud-controller-0 ansible_host=overcloud-controller-0 ansible_user=heat-admin ansible_private_key_file=/home/stack/.ssh/id_rsa [compute] overcloud-compute-1 overcloud-compute-0 [undercloud] undercloud [overcloud] overcloud-compute-1 overcloud-compute-0 overcloud-controller-2 overcloud-controller-1 overcloud-controller-0 [controller] overcloud-controller-2 overcloud-controller-1 overcloud-controller-0
SSH Arguments File
The SSH arguments file passes the necessary credentials and authentication settings that are needed by Ansible to run the playbooks on each target host.
Create the SSH arguments file from /home/stack with the following commands:
stack@director $ cat /home/stack/.ssh/id_rsa.pub >> /home/stack/.ssh/authorized_keys stack@director $ echo -e "Host undercloud\n Hostname 127.0.0.1\n IdentityFile /home/stack/.ssh/id_rsa\n User stack\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n" > ssh.config.ansible stack@director $ source /home/stack/stackrc stack@director $ openstack server list -c Name -c Networks | awk /ctlplane/ {print $2, $4} | sed s/ctlplane=//g | while read node; do node_name=$(echo $node | cut -f 1 -d " "); node_ip=$(echo $node | cut -f 2 -d " "); echo -e "Host $node_name\n Hostname $node_ip\n IdentityFile /home/stack/.ssh/id_rsa\n User heat-admin\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n"; done >> ssh.config.ansible
These commands create an SSH arguments file named ssh.config.ansible, which contains host-specific connection options for each overcloud node. For example:
Host overcloud-controller-0
Hostname 192.168.24.11
IdentityFile /home/stack/.ssh/id_rsa
User heat-admin
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null4.2. Preparing the Undercloud
After you create the inventory file and SSH arguments file, as described in Section 4.1, “Creating the Required Ansible Configuration Files”, you can prepare the undercloud for Instance HA.
-
Log in to the undercloud as the
stackuser. Clone the upstream
tripleo-ha-utilsgit repository.stack@director $ git clone git://github.com/openstack/tripleo-ha-utilsThis repository contains the playbooks, roles, and other utilities necessary to enable and test Instance HA with Ansible.
Create the /home/stack/ansible.cfg file with the following content:
[defaults] roles_path = /home/stack/tripleo-ha-utils/roles
Export the ansible.cfg file, the inventory file, and the SSH arguments file to the following environment variables:
stack@director $ export ANSIBLE_CONFIG="/home/stack/ansible.cfg" stack@director $ export ANSIBLE_INVENTORY="/home/stack/hosts" stack@director $ export ANSIBLE_SSH_ARGS="-F /home/stack/ssh.config.ansible"
- Make sure that the node definition template of the overcloud is located in /home/stack/. By default, the template file is named instackenv.json. For more information about the node definition template, see Registering Nodes for the Overcloud.
4.3. Enabling Instance HA
After you prepare the undercloud you can run the Ansible playbooks that you downloaded and extracted, as described in Section 4.2, “Preparing the Undercloud”. These playbooks allow you to enable Instance HA with or without configuring STONITH for the Controller and Compute nodes. For more information about STONITH, see Fencing the Controller Nodes.
- Enabling Instance HA with STONITH
To enable Instance HA and configure STONITH for both Controller and Compute nodes, run the following command:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12"By default, the playbook installs the
instance-hasolution with shared storage enabled. If your overcloud does not use shared storage, run the command with theinstance_ha_shared_storage=falseoption:stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12" -e instance_ha_shared_storage=falseNoteSee Section 3.1, “Considerations for Shared Storage” for more information about shared storage in Instance HA.
- Enabling Instance HA without STONITH
To enable Instance HA without configuring STONITH for the Controller and Compute nodes, run the following command:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12" -e stonith_devices="none"- Enabling Instance HA with STONITH only on the Compute nodes
To enable Instance HA and configure STONITH only on the Compute nodes (for example, if STONITH is already configured on the Controller nodes), run the following command:
stack@director $ ansible-playbook /home/stack/tripleo-ha-utils/playbooks/overcloud-instance-ha.yml \ -e release="rhos-12" -e stonith_devices="computes"
