1

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.

3 Answers 3

2

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

7
  • If I run it as you suggested I get prompted for 2 passwords, the first one is ssh password and the second one sudo password. I get errors if I enter the passwords correctly and if I enter the db2inst1 password both times.
    – warhansen
    Feb 13, 2017 at 14:52
  • 1
    @warhansen You really shouldn't be using password-enabled SSH. Use keys.
    – EEAA
    Feb 13, 2017 at 14:53
  • I have a ssh authorized_keys to log in but the still does not allow me to run commands on Ubuntu like it does on centos
    – warhansen
    Feb 13, 2017 at 14:56
  • You're confusing two things: ssh authentication and sudo. Ensure configuration parity between CentOS and Ubuntu and you won't have this issue.
    – EEAA
    Feb 13, 2017 at 15:02
  • The sftp subsystems in ubuntu and centos are different I think, so he has to watch for that - they are in different locations.
    – 13dimitar
    Feb 13, 2017 at 15:11
1

Give the full path to your db2 binary.

1
  • This seems to make sense: I tried: tasks: - name: setup svcename db2c_db2inst1 shell: /home/db2inst1/sqllib update database manager configuration using svcename db2c_db2inst1 remote_user: db2inst1 ------- Now I get permission denied
    – warhansen
    Feb 13, 2017 at 15:01
0

You would must load "db2profile" previously:

tasks:
  - name: setup svcename db2c_db2inst1
    shell: "$INSTANCEPATH/sqllib/db2profile; db2 update database manager configuration using svcename db2c_db2inst1"
    become: yes
    become_user: db2inst1

When $INSTANCEPATH is the path's home of db2 instance (e.g., /home/db2inst1)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .