3 minute read

A special shout out goes to JJ Asghar (IBM) and his coredns-playbook as it was a perfect starting point for a basic Ansible playbook.

This is a follow up on my previous post, “Install Information Server 11.7.1.1”, where I wrote my first Ansible playbook to automate the installation of Information Server 11.7.1.1. Even though I had been exposed to Ansible for quite some time I had never had the need to create or run any jobs myself. I figured this was a good opportunity to get my hands dirty.

Usual disclaimer: This document is for my own purpose to refer back to but if you find it useful then please let me know.

Prereqs

Install Ansible

brew install ansible

Install two other collections:

ansible-galaxy collection install community.general
ansible-galaxy collection install ansible.posix

Writing the playbook

I’ll post the main playbook here but check out the repo below for the other required files that store variables and includes a response file for IIS.

The latest version of the playbook is available here:

https://github.com/stevemar/datastage-playbook

---
- name: Install DataStage
  hosts: all

  tasks:
    - name: Fetch the variables from var file
      include_vars:
        file: ../vars/main.yml

    - name: Install DataStage dependencies
      yum:
        name:
          - unzip
          - ...
          - grep
        state: present

    - name: Upgrade all packages
      yum:
        name: '*'
        state: latest

    - name: Copy license files
      copy:
        src: "IS_V11711_EE_bundle_spec_file.zip"
        dest: /opt/IS_V11711_EE_bundle_spec_file.zip
        force: no

    - name: Copy install files
      copy:
        src: "IS_V11711_Linux_x86_multi.tar.gz"
        dest: /opt/IS_V11711_Linux_x86_multi.tar.gz
        force: no

    - name: Unarchive the install files
      unarchive:
        src: /opt/IS_V11711_Linux_x86_multi.tar.gz
        dest: /opt
        remote_src: yes

    - name: Unarchive the license file
      unarchive:
        src: /opt/IS_V11711_EE_bundle_spec_file.zip
        dest: /opt/is-suite
        remote_src: yes

    - name: Disable SELinux
      ansible.posix.selinux:
        state: disabled

    - name: Increase msgmax
      ansible.posix.sysctl:
        name: kernel.msgmax
        value: "65536"

    - name: Increase msgmnb
      ansible.posix.sysctl:
        name: kernel.msgmnb
        value: "65536"

    - name: Increase kernel semaphores
      ansible.posix.sysctl:
        name: kernel.sem
        value: "250 256000 32 1024"

    - name: Increase number of open files
      community.general.pam_limits:
        domain: root
        limit_type: "-"
        limit_item: nofile
        value: "65535"

    - name: Increase ulimit
      shell: ulimit -n 65535

    - name: Copy over config file
      ansible.builtin.template:
        src: ../templates/responsefile.txt
        dest: /opt/is-suite

    - name: Run pre-check
      shell:
        cmd: ./setup -reportOnly -rsp responsefile.txt
        chdir: /opt/is-suite/

    - name: Run installer
      shell:
        cmd: ./setup -rsp responsefile.txt -verbose
        chdir: /opt/is-suite/

The output

$ datastage-playbook ansible-playbook -i hosts -u root -k playbook/main.yaml

PLAY [Install DataStage] ************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************
ok: [169.x.y.z]

TASK [Fetch the variables from var file] ********************************************************************************************
ok: [169.x.y.z]

TASK [Install DataStage dependencies] ***********************************************************************************************
ok: [169.x.y.z]

TASK [Upgrade all packages] *********************************************************************************************************
ok: [169.x.y.z]

TASK [Copy license files] ***********************************************************************************************************
ok: [169.x.y.z]

TASK [Copy install files] ***********************************************************************************************************
ok: [169.x.y.z]

TASK [Unarchive the license file] ***************************************************************************************************
ok: [169.x.y.z]

TASK [Disable SELinux] **************************************************************************************************************
[WARNING]: SELinux state change will take effect next reboot
ok: [169.x.y.z]

TASK [Increase msgmax] **************************************************************************************************************
ok: [169.x.y.z]

TASK [Increase msgmnb] **************************************************************************************************************
ok: [169.x.y.z]

TASK [Increase kernel semaphores] ***************************************************************************************************
ok: [169.x.y.z]

TASK [Increase number of open files] ************************************************************************************************
ok: [169.x.y.z]

TASK [Increase ulimit] **************************************************************************************************************
changed: [169.x.y.z]

TASK [Copy over config file] ********************************************************************************************************
ok: [169.x.y.z]

TASK [Run pre-check] ****************************************************************************************************************
changed: [169.x.y.z]

TASK [Run installer] ****************************************************************************************************************

changed: [169.x.y.z]

PLAY RECAP **************************************************************************************************************************
169.x.y.z              : ok=16   changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

What did I learn?

That I should have learned Ansible a lot sooner. It was very easy to get up and running. The piece-meal nature of the playbook made it easy to comment out sections, clean up the remote machine, and run again until I got it right.

The one tricky part was finding out how to increase the number of open files allowed on the system. The community.general.pam_limits did the heavy lifting but I did need to re-run the ulimit -n 65535 command afterwards.

Summary

I’m glad I got this done as it looks like I’ll have to spin up a few of these servers in the coming weeks.

Updated: