Question

Using Ansible, is it possible to automate DB2ConfigTool --wizard?

  • 29 February 2024
  • 8 comments
  • 88 views

Userlevel 2

Hello Veeam,

My organization will be replacing Rubrik with Veeam to backup over 128+ production standalone DB2 database instances using Veeam Plugin for IBM DB2.Each of these database instances has a COLD DR site associated with it. We are running DB2 V11.5 Standard Edition on Linux RH. 

I’m trying to automate the installation and configuration of Veeam Plugin using Ansible. I was able to automate the installation portion. However, I’m looking for a way to automate the configuration piece, running the DB2ConfigTool --wizard.

I’m seeking your help, and I would appreciate your input.

 

Thank you


8 comments

Userlevel 7
Badge +17

Hi @rodeh65r -

Welcome to the Community Hub. Not sure I’ve seen any automation options for configuring any Veeam Plugin. Maybe someone else has & can assist. @Madi.Cristil @safiya ...I’m thinking since this question involves automation, this question post would be best served in the Automation Desk Group? Thoughts? At the very least, placed in the Discussions group so it gets more visibility?

Userlevel 2

@coolsport00 Thank you for posting this topic in the Automation Desk Group.

Userlevel 6
Badge +5

While  I’m unable to test this as I don’t have DB2 in my lab, in Veeam documentation, it mentions the configuration is stored in a configuration file as well as it lists configuration commands that can be used.

https://helpcenter.veeam.com/docs/backup/plugins/db2_configure.html?ver=120

Ansible could leverage these commands or generate a configuration file using its templating capability.

Hope this helps!

Userlevel 7
Badge +17

@rodeh65r - no problem at all. Hope doing so gives you some good leads!

Userlevel 7
Badge +7

@Markus.K1985 , any ideas on your side? 😊

 

 

Userlevel 2

Just an update.

I’m looking at the expect module. To use this module, you need to have the pexpect Python module installed on your Ansible control node. The pexpect module is a Python module that provides an interface to the expect command-line utility.

Userlevel 2

I don’t know if this Ansible playbook will work since I don’t have pexpect Python module installed on my Ansible control node, I wasn’t able to test it. I need to have my IS department to install it.  

 

---
- name: Configure DB2 using DB2ConfigTool
  hosts: hostname
  become: yes

  tasks:
    - name: Run DB2ConfigTool
      expect:
        command: /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --wizard

        responses:
          "Enter backup server name or IP address:" "veamtst.server.com"
          "Enter backup server port number [10006]:" "10006"
          "Enter username:" "veeamdomain\veeamdb2admin"
         (?i) "Enter password for veeamdomain\veeamdb2admin:" "MyPassw0rd01!"
          "Available backup repositories:" "1"
          "Do you want to use Veeam compression? (Y/n):" "n"
          "Do you want to apply logarchmeth1 configuration parameter? (Y/n):" "Y"
          "Save configuration?:" "1"
      register: db2config_output

    - name: Display the configuration
      debug: var=db2config_output.stdout_lines
 

Userlevel 2

After some error and trial, I was able to come up with an Ansible playbook that will install and configure Veeam Plugin for IBM DB2 using the following playbook.

---
- name: Install Veeam Plug-in for IBM Db2
  hosts: dbservernames
  gather_facts: false
  become: yes
  

  tasks:
    - name: Install Veeam | Copy Veeam Plug-in package 
      copy: 
        src: <path_name>/VeeamPluginforDB2-12.1.0.2131-1.x86_64.rpm 
        dest: /opt/
        mode: 0775

    - name: Install Veeam Plug-in package
      ansible.builtin.package:
        name: /opt/VeeamPluginforDB2-12.1.0.2131-1.x86_64.rpm
        state: present

      - name: Run DB2ConfigTool | Veeam Backup Server Name
      command: /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --set-host veeamsrvr.com
      become_user: "{{ instance_user }}"
    
    - name: Run DB2ConfigTool | Set Veeam Port Nnumber
      command: /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --set-port 10006
      become_user: "{{ instance_user }}" 

    - name: Run DB2ConfigTool | Set Veeam User Credinatials
      command: /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --set-credentials "domain\username" '<password>'
      become_user: "{{ instance_user }}"

    - name: Run DB2ConfigTool | Set Veeam Repository 
      shell: "echo 2 | /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --set-repository"
      become_user: "{{ instance_user }}"
     
    - name: Run DB2ConfigTool | Disable Veeam Compression
      command: /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --compression N
      become_user: "{{ instance_user }}"
 
    - name: Run DB2ConfigTool | Apply DB2 LOGARHMeth1 DB Configuration 
      command: /opt/veeam/VeeamPluginforDB2/DB2ConfigTool --set-logarchmeth Y
      become_user: "{{ instance_user }}"

 

Note: I had to use the shell module instead the command one to set the repository to pass my response with the echo and | (pipe). 

 

$ DB2ConfigTool --show-config

Backup server: veeamsrvr.com
Port: 10006
User name: veeamdb2admin
Domain name: testdomain
Veeam compression: Disabled
Delete orphaned backups after (days): Disabled
Restore from copy: Not configured
Repository: 
1. Linux Repo 2 - Cavern

Comment