Ansible – Run “command db2 update database manager configuration using svcename db2c_db2inst1” as db2 user

automationdb2

I am setting up ansible to install a DB2 on a linux server. Everything is working except in the last step I need to run:

db2 update database manager configuration using svcename db2c_db2inst1

However, I cannot seem to run that as a unprivileged user (I can run it as db2isnt1 user from cmd line and it works). The task I am using looks like this:

  tasks:
    - name: setup svcename db2c_db2inst1
      remote_user: db2inst1
      shell: db2 update database manager configuration using svcename db2c_db2inst1

but I get the following error:

TASK [setup svcename db2c_db2inst1]
******************************************** fatal: [db2ansible]: FAILED! => {"changed": true, "cmd": "db2 update database manager
configuration using svcename db2c_db2inst1", "delta":
"0:00:00.003631", "end": "2017-02-13 16:39:38.301753", "failed": true,
"rc": 127, "start": "2017-02-13 16:39:38.298122", "stderr": "/bin/sh:
1: db2: not found", "stdout": "", "stdout_lines": [], "warnings": []}

Any suggestions?

Thank you.

Warren.

Best Answer

Modify your last task like this:

tasks:
    - name: setup svcename db2c_db2inst1
      shell: db2 update database manager configuration using svcename db2c_db2inst1
      become: yes
      become_user: db2inst1

This will really execute the db2 command with db2inst1 user, which has the db2 executable in it's $PATH