Overview
This guide describes the steps to automate the installation of LifeKeeper on multiple nodes with Ansible based on a response file. It is primarily intended to be used as a reference by users who are already using Ansible when adding LifeKeeper into their environment. This guide provides a sample of the required Ansible tasks. The settings should be changed according to your environment.
Environment
In this document, we are creating a 2-node configuration.
OS: CentOS 8.0
Python: 3.6.8
Ansible: 2.9.9
LifeKeeper: 9.5.1
Setting up Targets to Install LifeKeeper
Configuring a Host Name and Name Resolution Service
LifeKeeper must be able to resolve target names in the cluster. Configure the DNS service or /etc/hosts so that name resolution can be performed between cluster nodes. In this guide we configure /etc/hosts on each node. The settings are changed as shown below.
hosts.yml
--- # Register all the hosts on which ansible is executed in /etc/hosts - name: update /etc/hosts lineinfile: dest: /etc/hosts state: present insertafter: EOF regexp: "^{{ item.address }}" line: "{{ item.address }}\t{{ item.hostname }}" with_items: - address: "10.1.6.88" hostname: "target1" - address: "10.1.6.89" hostname: "target2" - address: "10.1.6.87" hostname: "control-node"
Configuring a Firewall
If a firewall is enabled it is necessary to configure the firewall on each target. LifeKeeper communicates between targets using TCP port 7365. In this guide the port is set to the default: public zone.
firewall.yml
--- - name: enable lifekeeper port firewalld: zone: public port: 7365/tcp permanent: yes state: enabled register: firewalld - name: reload command: firewall-cmd --reload when: firewalld.changed
Configuring SELinux
In this case, SELinux is disabled. The settings are changed as shown below.
selinux.yml
--- - name: disable SELinux become: yes selinux: state=disabled register: selinux - name: reboot a node become: yes reboot: when: selinux.reboot_required
Preparing for LifeKeeper Installation and Licensing
In order to install LifeKeeper non-interactively, a response file is required. If you already have a response file you can skip this step.
- Download the create_response_file script.
The create_response_file script can be obtained from the same FTP directory that contains the LifeKeeper for Linux product image.
- Specify the file name and run the create_response_file script to create the configuration file.
# ./create_response_file /root/LifeKeeper/LKCONF
- When starting the create_response_file script the following menu screen is displayed.
- Select the Recovery Kits you want to install from the Recovery Kit Selection Menu.
- After setting up, select Done. Select Yes to exit and save the response file.
- Inspect the generated LKCONF file to confirm that your setup is correct. The following example shows a sample response file in which the user has selected the Oracle, PostgreSQL, MySQL, DataKeeper for Linux, and Apache Recovery Kits.
# LifeKeeper setup response file # DO NOT EDIT MANUALLY LKCONF_INSTALL_JRE="y" LKCONF_SELONLY="y" LKCONF_AUTH="y" LKCONF_LKUSER_lkadmin="root" LKCONF_steeleye_lkORA="y" LKCONF_steeleye_lkPGSQL="y" LKCONF_steeleye_lkSQL="y" LKCONF_steeleye_lkDR="y" LKCONF_steeleye_lkAPA="y"
Distribute each Obtained File and Specify the Directory
- Distribute the obtained installation image, licenses for all cluster nodes, and the previously created response file to the control-node machine. The following example shows the directory structure used in this guide.
/root/lifekeeper/ |- -sps.img: # LifeKeeper installation image |- -LKCONF: # Setup file for non-interactive LifeKeeper installation |- -licenses/ |- - target1 # Set of license files for target1 |- - target2 # Set of license files for target2
inventory
[targets] target1 target2
- Specify the directories to use.
defaults/main.yml
--- # Directory to save files required for installation on the control-node control_node_dir: /root/lifekeeper # Directory to save files that are temporarily required for installation on the target target_dir: /tmp/lifekeeper # Mount directory of the installation image on the target target_mnt: /mnt/LifeKeeper
The following steps must be performed on the targets.
Distribute the LifeKeeper Installation Image, License and Configuration File
deploy.yml
--- - name: deploy to lifekeeper install files copy: src: "{{ control_node_dir }}/" dest: "{{ target_dir }}"
Mount the LifeKeeper Installation Image
mount.yml
--- - name: mount setup image mount: path: "{{ target_mnt }}" src: "{{ target_dir }}/sps.img" fstype: iso9660 state: mounted
Install LifeKeeper
install.yml
--- - name: install lifekeeper shell: # If you run setup directly, it will fail. cmd: script -q -e -c "{{ target_mnt | quote }}/setup -f {{ target_dir | quote }}/LKCONF -q y" {{ target_dir | quote }}/lifekeeper_install.log
Add LifeKeeper Environment Changes
bash_profile.yml
--- - name: update lifekeeper PATH in bash_profile blockinfile: path: /root/.bash_profile marker: "# {mark} ANSIBLE MANAGED BLOCK: LifeKeeper" block: | PATH=$PATH:/opt/LifeKeeper/bin MANPATH=$MANPATH:/opt/LifeKeeper/man export PATH MANPATH
Installing the LifeKeeper License
license.yml
--- - name: install lifekeeper license shell: cmd: | for file in `ls`; do /opt/LifeKeeper/bin/lkcli license --file $file done chdir: "{{ target_dir }}/licenses/{{ inventory_hostname }}"
Start LifeKeeper
lkstart.yml
--- - name: start lifekeeper command: /opt/LifeKeeper/bin/lkcli start - name: lifekeeper status command: /opt/LifeKeeper/bin/lkcli status
Delete Unnecessary Files after Setting up LifeKeeper
clean.yml
--- - name: unmount a mounted lifekeeper image mount: path: "{{ target_mnt }}" state: absent - name: delete lifekeeper files file: path: "{{ target_dir }}" state: absent
Sample Ansible Playbook
Once all of the task files in the previous sections have been created, they can be combined to create a play similar to the one given in the example playbook shown below.
deploy_lifekeeper.yml
--- - name: deploy and install lifekeeper on all targets hosts: targets tasks: - include_vars: main.yml - include_tasks: hosts.yml - include_tasks: firewall.yml - include_tasks: selinux.yml - include_tasks: deploy.yml - include_tasks: mount.yml - include_tasks: install.yml - include_tasks: bash_profile.yml - include_tasks: license.yml - include_tasks: lkstart.yml - include_tasks: clean.yml
This sample playbook can be executed as root with the command:
# ansible-playbook deploy_lifekeeper.yml -i inventory
or can be incorporated into an existing Ansible playbook.
After completing all tasks described in this guide, Ansible has been successfully configured to automatically install LifeKeeper on all cluster nodes specified in the inventory file.
Post your comment on this topic.