diff --git a/packaging/ansible/ubuntu/README.txt b/packaging/ansible/ubuntu/README.txt
new file mode 100644
index 00000000..5e4fac4f
--- /dev/null
+++ b/packaging/ansible/ubuntu/README.txt
@@ -0,0 +1,6 @@
+install ansible
+ sudo yum install epel-release
+ sudo yum install ansible
+install ansible modules
+ ansible-galaxy collection install ansible.utils
+Edit /etc/ansible/hosts and add 127.0.0.1
diff --git a/packaging/ansible/ubuntu/gofr.yaml b/packaging/ansible/ubuntu/gofr.yaml
new file mode 100644
index 00000000..f677c474
--- /dev/null
+++ b/packaging/ansible/ubuntu/gofr.yaml
@@ -0,0 +1,95 @@
+---
+- name: GOFR Installation into /var/lib/gofr
+ hosts: all
+ # gather_facts: false
+ tasks:
+ - pause:
+ prompt: "Please enter the name of the site without space"
+ register: result
+ until: result.user_input is not search(' ')
+ retries: 3
+ delay: 0
+ - set_fact:
+ site: "{{ result.user_input }}"
+
+ - name: Clonning GOFR github repo
+ git:
+ repo: 'https://github.com/intrahealth/gofr.git'
+ dest: /var/lib/gofr
+ clone: yes
+ force: yes
+
+ - name: Creating GOFR backend site
+ file:
+ path: /var/lib/gofr/gofr-backend/{{site}}
+ state: directory
+
+ - name: Copying GOFR backend site
+ copy:
+ src: /var/lib/gofr/gofr-backend/lib/gofr-backend-site/
+ dest: /var/lib/gofr/gofr-backend/{{site}}
+
+ - name: Creating GOFR frontend site
+ file:
+ path: /var/lib/gofr/gofr-gui/src/site
+ state: directory
+
+ - name: Copying GOFR frontend site
+ copy:
+ src: /var/lib/gofr/gofr-gui/src/gofr-frontend-site/
+ dest: /var/lib/gofr/gofr-gui/src/site
+
+ - name: Installing npm packages into gofr-backend
+ shell: |
+ cd /var/lib/gofr/gofr-backend
+ npm install
+
+ - name: Installing npm packages into {{site}}
+ shell: |
+ cd /var/lib/gofr/gofr-backend/{{site}}
+ npm install
+
+ - name: Installing npm packages into gofr-gui
+ shell: |
+ cd /var/lib/gofr/gofr-gui
+ npm install
+
+ - name: Installing configuration
+ copy:
+ src: /var/lib/gofr/gofr-backend/{{site}}/config/default.json.example
+ dest: /var/lib/gofr/gofr-backend/{{site}}/config/default.json
+
+ - name: Reading configuration file
+ ansible.builtin.set_fact:
+ configfile: "{{ lookup('file', '/var/lib/gofr/gofr-backend/{{site}}/config/default.json') }}"
+
+ - name: Updating configuration file
+ ansible.utils.update_fact:
+ updates:
+ - path: configfile.app.site.path
+ value: /var/lib/gofr/gofr-backend/{{site}}
+ - path: configfile.mCSD.server.basePath
+ value: fhir
+ register: updated
+
+ - name: Saving configuration file
+ copy: content="{{ updated.configfile | to_nice_json }}" dest="/var/lib/gofr/gofr-backend/{{site}}/config/default.json"
+
+ - name: Getting path of node
+ command: which node
+ register: node_path
+ ignore_errors: yes
+
+ - name: Install systemd template for gofr service
+ template:
+ src: gofr.service.j2
+ dest: /etc/systemd/system/gofr.service
+ mode: 0755
+ force: yes
+
+ - name: Start and Enable GOFR
+ service:
+ name: gofr
+ state: started
+ enabled: yes
+ daemon_reload: yes
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/hapi.yaml b/packaging/ansible/ubuntu/hapi.yaml
new file mode 100644
index 00000000..a4077de9
--- /dev/null
+++ b/packaging/ansible/ubuntu/hapi.yaml
@@ -0,0 +1,118 @@
+---
+- name: HAPI FHIR Server
+ hosts: all
+ # become: true
+ tags: prep
+
+ tasks:
+
+ - name: Add the OS specific variables
+ include_vars:
+ file: index.yaml
+
+ - name: hapi folder exists
+ stat:
+ path: /tmp/hapi-fhir-jpaserver-starter
+ register: stat_result2
+
+
+ - name: git clone repo hapi-jpa-server-starter
+ git:
+ repo: 'https://github.com/hapifhir/hapi-fhir-jpaserver-starter.git'
+ dest: /tmp/hapi-fhir-jpaserver-starter
+ clone: yes
+ force: yes
+ when: stat_result2.stat.exists == False
+
+
+ - name: git pull if updated
+ git:
+ repo: 'https://github.com/hapifhir/hapi-fhir-jpaserver-starter.git'
+ dest: /tmp/hapi-fhir-jpaserver-starter
+ update: yes
+ force: yes
+
+
+ - name: git checkout v{{hapi_ver}}
+ shell: git checkout v{{hapi_ver}}
+ args:
+ chdir: /tmp/hapi-fhir-jpaserver-starter
+
+
+ - name: install application.yaml template for hapi jpa Server
+ template:
+ src: ../570-application.yaml
+ dest: /tmp/hapi-fhir-jpaserver-starter/src/main/resources/application.yaml
+ owner: "tomcat"
+ group: "tomcat"
+ mode: 0755
+ force: yes
+
+
+ - name: Building hapi-fhir
+ shell: /opt/maven/bin/mvn clean install --no-transfer-progress --batch-mode package -DskipTests
+ args:
+ chdir: /tmp/hapi-fhir-jpaserver-starter
+ environment:
+ MAVEN_OPTS: -Xmx2048m
+
+
+ # stop tomcat
+ - name: stop tomcat
+ service:
+ name: tomcat
+ state: stopped
+ become: true
+
+ # pause to let tomcat stop
+ - pause:
+ seconds: 10
+
+
+ # move default ROOT into ROOT-Closed
+ - name: move default ROOT into ROOT-Closed
+ file:
+ path: /opt/tomcat{{tomcat_v_num}}/webapps/ROOT
+ state: absent
+
+ - name: move war file to /opt/tomcat{{tomcat_v_num}}/webapps/
+ shell: cp ROOT.war /opt/tomcat{{tomcat_v_num}}/webapps/
+ args:
+ chdir: /tmp/hapi-fhir-jpaserver-starter/target/
+ become: true
+
+
+ - name: create lucene target
+ ansible.builtin.file:
+ path: /opt/tomcat{{tomcat_v_num}}/target
+ state: directory
+ # needs broad perms
+ mode: '0777'
+ owner: tomcat
+ group: tomcat
+ become: true
+
+ - name: create lucenefiles
+ ansible.builtin.file:
+ path: /opt/tomcat{{tomcat_v_num}}/target/lucenefiles
+ state: directory
+ mode: '0777'
+ owner: tomcat
+ group: tomcat
+ become: true
+
+ - name: restart tomcat
+ systemd:
+ name: tomcat
+ state: started
+
+ - pause:
+ seconds: 10
+
+ - name: status
+ command: systemctl status tomcat.service
+ register: status
+
+
+ - debug:
+ msg: "{{ status.stdout_lines }}"
diff --git a/packaging/ansible/ubuntu/maven.yaml b/packaging/ansible/ubuntu/maven.yaml
new file mode 100644
index 00000000..08df71e2
--- /dev/null
+++ b/packaging/ansible/ubuntu/maven.yaml
@@ -0,0 +1,42 @@
+---
+- name: Install Apache Maven on CentOS
+ hosts: all
+
+ tasks:
+ - name: Add the OS specific variables
+ include_vars:
+ file: index.yaml
+
+ - name: Download Apache Maven
+ get_url:
+ url: "https://archive.apache.org/dist/maven/maven-{{maven_v_num}}/{{maven_ver}}/binaries/apache-maven-{{maven_ver}}-bin.tar.gz"
+ dest: "/tmp/apache-maven-{{maven_ver}}-bin.tar.gz"
+ mode: '0644'
+
+ - name: Extract Apache Maven
+ ansible.builtin.unarchive:
+ src: "/tmp/apache-maven-{{maven_ver}}-bin.tar.gz"
+ dest: "/opt/"
+ remote_src: yes
+ creates: "/opt/apache-maven-{{maven_ver}}"
+
+ - name: Create Symbolic Link for Maven
+ ansible.builtin.file:
+ src: "/opt/apache-maven-{{maven_ver}}"
+ dest: "/opt/maven"
+ state: link
+
+ - name: Set Environment Variables for Maven
+ ansible.builtin.copy:
+ content: |
+ export M2_HOME=/opt/maven
+ export M2=$M2_HOME/bin
+ export PATH=$M2:$PATH
+ dest: "/etc/profile.d/maven.sh"
+ notify: Reload Environment Variables
+
+ handlers:
+ - name: Reload Environment Variables
+ shell: source /etc/profile.d/maven.sh
+ args:
+ executable: /bin/bash
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/postgresinstall.yaml b/packaging/ansible/ubuntu/postgresinstall.yaml
new file mode 100644
index 00000000..a0d96bdf
--- /dev/null
+++ b/packaging/ansible/ubuntu/postgresinstall.yaml
@@ -0,0 +1,58 @@
+---
+- name: Install PostgreSQL 9 or above
+ hosts: all
+ remote_user: root
+ become: yes
+
+ tasks:
+
+ - name: Install PostgreSQL
+ apt:
+ name: ['postgresql', 'postgresql-contrib']
+ state: present
+
+ - name: Start and enable PostgreSQL
+ systemd:
+ name: postgresql
+ enabled: yes
+ state: started
+
+ - name: Gather PostgreSQL Information
+ become: true
+ become_user: postgres
+ community.postgresql.postgresql_info:
+ register: postgres_info
+
+ - name: Create a new database with name hapi
+ postgresql_db:
+ name: hapi
+ become: true
+ become_user: postgres
+
+ - name: Create hapi user, and grant access to hapi database
+ no_log: true
+ postgresql_user:
+ db: hapi
+ name: hapi
+ password: hapi
+ priv: ALL
+ become: true
+ become_user: postgres
+
+ - name: Allow md5 connection for the db user
+ postgresql_pg_hba:
+ dest: "/etc/postgresql/{{postgres_info.version.major}}/main/pg_hba.conf"
+ contype: host
+ databases: all
+ method: md5
+ users: hapi
+ create: true
+ become: yes
+ become_user: postgres
+ notify: restart postgresql
+
+ handlers:
+ - name: restart postgresql
+ systemd:
+ name: postgresql
+ state: restarted
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/prep.yaml b/packaging/ansible/ubuntu/prep.yaml
new file mode 100644
index 00000000..b288b0c6
--- /dev/null
+++ b/packaging/ansible/ubuntu/prep.yaml
@@ -0,0 +1,53 @@
+---
+- name: Installing supporting packages
+ hosts: all
+ become: yes
+
+ tasks:
+
+ - name: Updating apt cache
+ apt:
+ update_cache: yes
+
+ - name: Install basic packages
+ apt:
+ name: ['git', 'python3-psycopg2']
+ state: present
+
+ - name: Install Redis
+ apt:
+ name: redis-server
+ state: present
+
+ - name: Start redis
+ service:
+ name: redis
+ state: started
+ enabled: yes
+
+ - name: Download NodeSource setup script
+ get_url:
+ url: https://deb.nodesource.com/setup_18.x
+ dest: /tmp/setup_node.sh
+
+ - name: Execute NodeSource setup script
+ command: /bin/bash /tmp/setup_node.sh
+
+ - name: Install Node.js
+ apt:
+ name: nodejs
+ state: present
+
+ - name: Remove temporary setup script
+ file:
+ path: /tmp/setup_node.sh
+ state: absent
+
+ # - name: Install npm
+ # apt:
+ # name: npm
+ # state: present
+
+ - name: Install fsh-sushi
+ shell: |
+ npm install -g fsh-sushi
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/run.sh b/packaging/ansible/ubuntu/run.sh
new file mode 100644
index 00000000..9f9e1cf5
--- /dev/null
+++ b/packaging/ansible/ubuntu/run.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -ex
+
+# this only works for vagrant ubuntu instances (localhost)
+# --forks 1 to stop hosts checking on first run: https://github.com/ansible/ansible/issues/25068
+ansible-playbook prep.yaml --connection=local
+ansible-playbook postgresinstall.yaml --connection=local
+ansible-playbook tomcat.yaml --connection=local
+ansible-playbook maven.yaml --connection=local
+ansible-playbook hapi.yaml --connection=local
+ansible-playbook gofr.yaml --connection=local
diff --git a/packaging/ansible/ubuntu/templates/context.xml.j2 b/packaging/ansible/ubuntu/templates/context.xml.j2
new file mode 100644
index 00000000..aa6c09e4
--- /dev/null
+++ b/packaging/ansible/ubuntu/templates/context.xml.j2
@@ -0,0 +1,19 @@
+
+
+
+
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/templates/gofr.service.j2 b/packaging/ansible/ubuntu/templates/gofr.service.j2
new file mode 100644
index 00000000..fb8fa220
--- /dev/null
+++ b/packaging/ansible/ubuntu/templates/gofr.service.j2
@@ -0,0 +1,14 @@
+[Unit]
+Description=GOFR
+Documentation=https://gofr.org
+After=network.target
+
+[Service]
+Type=simple
+WorkingDirectory=/var/lib/gofr/gofr-backend
+ExecStart={{node_path}} /var/lib/gofr/gofr-backend/{{site}}/bin/www
+Restart=always
+Environment=NODE_ENV=production
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/templates/tomcat-users.xml.j2 b/packaging/ansible/ubuntu/templates/tomcat-users.xml.j2
new file mode 100644
index 00000000..e5441fde
--- /dev/null
+++ b/packaging/ansible/ubuntu/templates/tomcat-users.xml.j2
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/templates/tomcat.j2 b/packaging/ansible/ubuntu/templates/tomcat.j2
new file mode 100644
index 00000000..c4cfb608
--- /dev/null
+++ b/packaging/ansible/ubuntu/templates/tomcat.j2
@@ -0,0 +1,49 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: Tomcat
+# Required-Start: $all
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: Tomcat Server basic start/shutdown script
+### END INIT INFO
+
+TOMCAT_HOME=/opt/tomcat{{tomcat_v_num}}/bin
+START_TOMCAT=/opt/tomcat{{tomcat_v_num}}/bin/startup.sh
+STOP_TOMCAT=/opt/tomcat{{tomcat_v_num}}/bin/shutdown.sh
+
+start() {
+ echo -n "Starting tomcat: "
+ cd $TOMCAT_HOME
+ ${START_TOMCAT}
+ echo "done."
+}
+
+stop() {
+ echo -n "Shutting down tomcat: "
+ cd $TOMCAT_HOME
+ ${STOP_TOMCAT}
+ echo "done."
+}
+
+case "$1" in
+
+start)
+ start
+ ;;
+
+stop)
+ stop
+ ;;
+
+restart)
+ stop
+ sleep 10
+ start
+ ;;
+
+*)
+ echo "Usage: $0 {start|stop|restart}"
+
+esac
+exit 0
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/templates/tomcat.service.j2 b/packaging/ansible/ubuntu/templates/tomcat.service.j2
new file mode 100644
index 00000000..a51f20bd
--- /dev/null
+++ b/packaging/ansible/ubuntu/templates/tomcat.service.j2
@@ -0,0 +1,22 @@
+[Unit]
+Description=Tomcat
+After=syslog.target network.target
+
+[Service]
+Type=forking
+
+User=tomcat
+Group=tomcat
+
+Environment=JAVA_HOME={{ JAVA_HOME }}
+Environment='JAVA_OPTS=-Djava.awt.headless=true'
+
+Environment=CATALINA_HOME=/opt/tomcat{{tomcat_v_num}}
+Environment=CATALINA_BASE=/opt/tomcat{{tomcat_v_num}}
+Environment=CATALINA_PID=/opt/tomcat{{tomcat_v_num}}/temp/tomcat.pid
+
+ExecStart=/opt/tomcat{{tomcat_v_num}}/bin/catalina.sh start
+ExecStop=/opt/tomcat{{tomcat_v_num}}/bin/catalina.sh stop
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/tomcat.yaml b/packaging/ansible/ubuntu/tomcat.yaml
new file mode 100644
index 00000000..4cf2a0b9
--- /dev/null
+++ b/packaging/ansible/ubuntu/tomcat.yaml
@@ -0,0 +1,95 @@
+---
+- name: Installing Apache tomcat{{tomcat_v_num}}
+ hosts: all
+ tasks:
+ - name: Add the OS specific variables
+ include_vars:
+ file: index.yaml
+
+ - name: Download JDK 17
+ get_url:
+ url: "https://download.oracle.com/java/{{java_ver}}/latest/jdk-{{java_ver}}_linux-x64_bin.deb"
+ dest: "/tmp/jdk-{{java_ver}}.deb"
+
+ - name: Installing JDK {{java_ver}}
+ ansible.builtin.apt: deb="/tmp/jdk-{{java_ver}}.deb"
+
+ - name: Add tomcat group
+ group:
+ name: tomcat
+
+ - name: Add "tomcat" user
+ user:
+ name: tomcat
+ group: tomcat
+ home: /opt/tomcat{{tomcat_v_num}}
+ createhome: no
+ system: yes
+
+ - name: Create a Tomcat Directory
+ file:
+ path: /opt/tomcat{{tomcat_v_num}}
+ owner: tomcat
+ group: tomcat
+ mode: 755
+ recurse: yes
+
+ - name: download & unarchive tomcat{{tomcat_v_num}}
+ unarchive:
+ src: https://archive.apache.org/dist/tomcat/tomcat-{{tomcat_v_num}}/v{{tomcat_ver}}/bin/apache-tomcat-{{tomcat_ver}}.tar.gz
+ dest: /opt/tomcat{{tomcat_v_num}}
+ remote_src: yes
+ extra_opts: [--strip-components=1]
+
+ - name: Change ownership of tomcat directory
+ file:
+ path: /opt/tomcat{{tomcat_v_num}}
+ owner: tomcat
+ group: tomcat
+ mode: "u+rwx,g+rx,o=rx"
+ recurse: yes
+ state: directory
+
+ - name: Copy tomcat service file
+ template:
+ src: templates/tomcat.j2
+ dest: /etc/init.d/tomcat
+ when: ansible_service_mgr == "systemd"
+
+ - name: Create symlink to start/stop/restart tomcat
+ file:
+ src: /etc/init.d/tomcat
+ dest: /etc/rc2.d/S99tomcat
+ state: link
+
+ - name: Making tomcat service executable by users
+ file:
+ path: /etc/init.d/tomcat
+ mode: "ugo=x"
+
+ - name: Start tomcat
+ service:
+ name: tomcat
+ enabled: yes
+ state: started
+
+ - name: Set UI access credentials
+ template:
+ src: tomcat-users.xml.j2
+ dest: /opt/tomcat{{tomcat_v_num}}/conf/tomcat-users.xml
+ notify: restart tomcat
+
+ - name: Allow access to Manager and Host Manager apps from any IP
+ template:
+ src: context.xml.j2
+ dest: "{{ item }}"
+ with_items:
+ - /opt/tomcat{{tomcat_v_num}}/webapps/host-manager/META-INF/context.xml
+ - /opt/tomcat{{tomcat_v_num}}/webapps/manager/META-INF/context.xml
+ notify: restart tomcat
+
+ handlers:
+ - name: restart tomcat
+ service:
+ name: tomcat
+ state: restarted
\ No newline at end of file
diff --git a/packaging/ansible/ubuntu/vars/index.yaml b/packaging/ansible/ubuntu/vars/index.yaml
new file mode 100644
index 00000000..fca6aedd
--- /dev/null
+++ b/packaging/ansible/ubuntu/vars/index.yaml
@@ -0,0 +1,18 @@
+#JAVA
+JAVA_HOME: /usr/lib/jvm/jdk-17-oracle-x64
+java_ver: 17
+
+#tomcat
+tomcat_ver: 9.0.80 # Tomcat version to install
+tomcat_v_num: 9 # Tomcat version number
+ui_manager_user: manager # User who can access the UI manager section only
+ui_manager_pass: Str0ngManagerP@ssw3rd # UI manager user password
+ui_admin_username: admin # User who can access bpth manager and admin UI sections
+ui_admin_pass: Str0ngAdminP@ssw3rd # UI admin password
+
+#maven
+maven_ver: 3.9.4
+maven_v_num: 3
+
+#hapi
+hapi_ver: 5.7.0
\ No newline at end of file