Installing Bahmni on separate servers

Hello Community

I have a Bahmni Dev installation on one server for both App and DB, but for Production the requirement is to separate the App and the DB. How do I go about this because Bahmni installation is automated through several scripts.

You can change your inventory file /etc/bahmni-installer/local for set-up application & database in multiple server. Here is the Documentation Link Please see this. Sample inventory file Link . You can put other server ip address in the inventory file & try bahmni install command.

Thanks @rakib.hasan for pointing me to the article. I just want to confirm that everything is in order before I proceed with the installtion. My 2 servers are as follows

  • Application: 192.168.32.1
  • Database: 192.168.32.2

So these are the steps I have done so far (I want all databases installed on DB Server, and all other components on App Server)

  1. Installed Bahmni Installer using command > yum install https: //dl .bintray.com /bahmni/rpm/rpms/bahmni-installer-0 .92-142.noarch.rpm #version 0.92

  2. Edited the inventory file at /opt/bahmni-installer/bahmni-playbooks/local and this is how my file looks like

@rakib.hasan any luck? Did you check my inventory file?

Hello @tapologo, In the inventory file you should add the host ip of your application & db server with ansible_user & ansible_private_key_file like link.

You can see @angshuonline reply Link

I can describe in short about ssh access & ansible in the bellow:

We can use-

  • Application server(192.168.33.10),
  • database server(192.168.33.11) &
  • another control machine.

In Control Machine we will install bahmni installer & edited the inventory file like above mentioned pestbin link. The requirement of ansible’s remote access is : sudo access to application & database server. We can do it by generating ssh-keygen command & you can study from here.

In each server we need to generate ssh-key by executing ssh-keygen & copy authorized key to other servers by executing ssh-copy user@server_ip. After this, We need to install ansible in control machine and add the bellow lines in /etc/ansible/hosts file:

192.168.33.10 ansible_user=root ansible_private_key_file=/root/.ssh/id_rsa
192.168.33.11 ansible_user=root ansible_private_key_file=/root/.ssh/id_rsa

And we can test ansible access by executing ansible all -a “/bin/echo hello” and get the bellow result if all configuration is correctly done.

192.168.33.10 | SUCCESS | rc=0 >>
hello
192.168.33.11 | SUCCESS | rc=0 >>
hello

after that if you need edit bahmni setup file please edit it & start bahmni install by executing bahmni -i local install. I have tested in bahmni 0.91. So please do it in bahmni 0.91 first & then 0.92.

@rakib.hasan When we followed the same process for master slave set up, it installed Bahmni on master and databases on both (master and slave) but the databases do not sync with each other ie when a patient is created from Bahmni it gets stored only in master db but not in slave. Any pointers to isolate the reason? And of course the subsequent follow up to resolve our issue. Tested on Bahmni 0.91.

Hello @akshaybirajdar, I think, you may be miss the replica setup command:

  • To setup mysql replication, following command needs to be executed:

    bahmni -i <inventory_file_name> setup-mysql-replication
    
  • To setup postgres replication, following command needs to be executed:

     bahmni -i <inventory_file_name> setup-postgres-replication
    

For details please see the link

I have tested the master-slave setup in bahmni 0.91 & successfully sync with slave on any update on master db. I made my inventory file like this file.

@rakib.hasan Thank you, we will try these steps and will try same with Bahmni 0.92.

Thanks @rakib.hasan for your detailed instructions. I followed everything but still struggling with installation. I managed to create the inventory file and it’s working properly, however I noticed that on the remote DB server, mysql gets installed successfully but the openmrs schema is not created. See below list of my current databases

mysql> show databases;
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| mysql                |
| performance_schema   |
| sys                  |
+----------------------+
4 rows in set (0.00 sec)

The other thing, after running the installer, when I check I only see that the Bahmni Installer got installed, everything else did not

# yum list installed | grep bahmni
bahmni-installer.noarch            0.92-142      @/bahmni-installer-0.92-142.noarch

This is the message I get after running bahmni -i inventory install

fatal: [10.12.0.2]: FAILED! => {"changed": false, "module_stderr": "Shared connection to 10.12.0.2 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_shtYTU/ansible_module_mysql_user.py\", line 218, in <module>\r\n    from ansible.module_utils.basic import AnsibleModule\r\nzlib.error: Error -2 while preparing to decompress data: inconsistent stream state\r\n", "msg": "MODULE FAILURE", "rc": 0}
        to retry, use: --limit @/opt/bahmni-installer/bahmni-playbooks/all.retry

PLAY RECAP ******************************************************************************************************************************************************************************
10.12.0.2                  : ok=62   changed=25   unreachable=0    failed=1
localhost                  : ok=45   changed=12   unreachable=0    failed=0

Traceback (most recent call last):
  File "/bin/bahmni", line 11, in <module>
    load_entry_point('bahmni==0.1', 'console_scripts', 'bahmni')()
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "build/bdist.linux-x86_64/egg/bahmni.py", line 79, in install
  File "/usr/lib64/python2.7/subprocess.py", line 542, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'ansible-playbook -i /etc/bahmni-installer/inventory all.yml -vv  --extra-vars '@/etc/bahmni-installer/rpm_versions.yml' --extra-vars '@/etc/bahmni-backrest.conf' --extra-vars '@/etc/bahmni-installer/setup.yml'' returned non-zero exit status 2

Here’s some additional information

$ ansible -m ping all -vvv
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/user-2/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/ping.py
<10.12.0.2> ESTABLISH SSH CONNECTION FOR USER: user-2
<10.12.0.2> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/user-2/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user-2-o ConnectTimeout=10 -o ControlPath=/home/user-2/.ansible/cp/247fd1b7c0 10.12.0.2 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/ping.py
<10.12.0.1> ESTABLISH SSH CONNECTION FOR USER: user-1
<10.12.0.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/user-1/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=user-1 -o ConnectTimeout=10 -o ControlPath=/home/user-2/.ansible/cp/2eb3ad4ce2 10.12.0.1 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<10.12.0.2> (255, '', 'no such identity: /user-2/.ssh/id_rsa: No such file or directory\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
10.12.0.2 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: no such identity: /user-2/.ssh/id_rsa: No such file or directory\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
    "unreachable": true
}
<10.12.0.1> (255, '', 'no such identity: /user-1/.ssh/id_rsa: No such file or directory\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n')
10.12.0.1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: no such identity: /user-1/.ssh/id_rsa: No such file or directory\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
    "unreachable": true
}

Ping is now working. However when I ran the installer I still get an error

bahmni -i inventory install
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.ufs.ac.za
 * epel: fedora-epel.mirrors.tds.net
 * extras: mirror.ufs.ac.za
 * updates: mirror.ufs.ac.za
Package matching ansible-2.4.2.0-2.el7.noarch already installed. Checking for update.
Nothing to do
ansible-playbook -i /etc/bahmni-installer/inventory all.yml -vv  --extra-vars '@/etc/bahmni-installer/rpm_versions.yml' --extra-vars '@/etc/bahmni-backrest.conf' --extra-vars '@/etc/bahmni-installer/setup.yml'
ansible-playbook 2.8.5
  config file = /opt/bahmni-installer/bahmni-playbooks/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible-playbook
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /opt/bahmni-installer/bahmni-playbooks/ansible.cfg as config file
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user
configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in
ansible.cfg.
 [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' (default). This feature will be removed in version
2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/oracle-java/tasks/oracle-java.yml
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/installer-config/tasks/installer-config.yml
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/selinux/tasks/enforcing_policies.yml
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/installer-config/tasks/installer-config.yml
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/installer-config/tasks/installer-config.yml
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/oracle-java/tasks/oracle-java.yml
statically imported: /opt/bahmni-installer/bahmni-playbooks/roles/installer-config/tasks/installer-config.yml
ERROR! 'always' keyword cannot be used without 'block'

The error appears to be in '/opt/bahmni-installer/bahmni-playbooks/roles/bahmni-backup-upload-directories/tasks/main.yml': line 14, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- always:
  ^ here

Traceback (most recent call last):
  File "/bin/bahmni", line 11, in <module>
    load_entry_point('bahmni==0.1', 'console_scripts', 'bahmni')()
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "build/bdist.linux-x86_64/egg/bahmni.py", line 79, in install
  File "/usr/lib64/python2.7/subprocess.py", line 542, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'ansible-playbook -i /etc/bahmni-installer/inventory all.yml -vv  --extra-vars '@/etc/bahmni-installer/rpm_versions.yml' --extra-vars '@/etc/bahmni-backrest.conf' --extra-vars '@/etc/bahmni-installer/setup.yml'' returned non-zero exit status 4

I’m Facing issue when I’m using two different for

  • Application server(192.168.33.10),
  • database server(192.168.33.11) I follow all steps mentioned above . also ansible is pinging correctly Also able to install MySQL in DB server but Error at “TASK [mysql-users : ensure anonymous users are not in the database]” @angshuonline @rakib.hasan

Can @rakib.hasan,you help me out?

  PLAY [mysql-backup-tool] ***********************************************************************************************************************************************

    PLAY [postgres-backup-tool] ********************************************************************************************************************************************
            to retry, use: --limit @/opt/bahmni-installer/bahmni-playbooks/all.retry

    PLAY RECAP *************************************************************************************************************************************************************
    15.206.66.110              : ok=113  changed=43   unreachable=0    failed=1
    35.154.138.178             : ok=136  changed=53   unreachable=0    failed=1

    Traceback (most recent call last):
      File "/bin/bahmni", line 11, in <module>
        load_entry_point('bahmni==0.1', 'console_scripts', 'bahmni')()
      File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 764, in __call__
        return self.main(*args, **kwargs)
      File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 717, in main
        rv = self.invoke(ctx)
      File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 956, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 555, in invoke
        return callback(*args, **kwargs)
      File "/usr/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/decorators.py", line 17, in new_func
        return f(get_current_context(), *args, **kwargs)
      File "build/bdist.linux-x86_64/egg/bahmni.py", line 79, in install
      File "/usr/lib64/python2.7/subprocess.py", line 542, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command 'ansible-playbook -i /etc/bahmni-installer/local all.yml -vv  --extra-vars '@/etc/bahmni-installer/rpm_versions.yml' --extra-vars '@/etc/bahmni-backrest.conf' --extra-vars '@/etc/bahmni-installer/setup.yml'' returned non-zero exit status 2`Preformatted text`

I also tried for passive server in that I got stuck on this:

Please help me out.

HI @rakib.hasan, after following the steps you mentioned I am getting this message:

3.76.31.237 | UNREACHABLE! => { “changed”: false, “msg”: “Failed to connect to the host via ssh: Permission denied (publickey).\r\n”, “unreachable”: true }

The two servers that I am trying to connect, one for database and the other for Bahmni are running in AWS. Any ideas?