From c4d974c987c133fdb7ef05b955f00b867fdd88a7 Mon Sep 17 00:00:00 2001
From: "Vancea, Ioan (ivancea)" <ioan.vancea@physik.hu-berlin.de>
Date: Mon, 29 Jan 2018 15:20:41 +0100
Subject: [PATCH] Added the new CentOS production machine as deployment option
 for GUI - right now manual only trigger

---
 .gitlab-ci.yml                                | 23 +++++++++++++++----
 deploy/hosts                                  |  5 +++-
 deploy/playbook-production-centos.yml         | 23 +++++++++++++++++++
 ...ction.yml => playbook-production-suse.yml} |  2 +-
 4 files changed, 46 insertions(+), 7 deletions(-)
 create mode 100644 deploy/playbook-production-centos.yml
 rename deploy/{playbook-production.yml => playbook-production-suse.yml} (97%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7c2c5870..2e3e8605 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,7 @@
 stages:
   - Deploy On Testing
-  - Deploy On Production
+  - Deploy On ProductionCentOS
+  - Deploy On ProductionSUSE
 
 Deploy Testing:
   stage: Deploy On Testing
@@ -15,14 +16,26 @@ Deploy Testing:
   only:
     - master
 
-Deploy Production:
-  stage: Deploy On Production
+Deploy ProductionCentOS:
+  stage: Deploy On ProductionCentOS
   script:
     - pwd
     - source /home/deploy/ansible-provision/ansible-venv/bin/activate
     - cd deploy
-    - ansible-playbook -i hosts playbook-production.yml
-    - echo "Deployed On Production -> DONE"
+    - ansible-playbook -i hosts playbook-production-centos.yml
+    - echo "Deployed On Production CentOS-> DONE"
+    - ls -al
+    - pwd
+  when: manual
+
+Deploy ProductionSUSE:
+  stage: Deploy On ProductionSUSE
+  script:
+    - pwd
+    - source /home/deploy/ansible-provision/ansible-venv/bin/activate
+    - cd deploy
+    - ansible-playbook -i hosts playbook-production-suse.yml
+    - echo "Deployed On Production SUSE -> DONE"
     - ls -al
     - pwd
   when: manual
diff --git a/deploy/hosts b/deploy/hosts
index eb8a39c9..4620694f 100644
--- a/deploy/hosts
+++ b/deploy/hosts
@@ -1,5 +1,8 @@
 [testing]
 enc-testing-nomad.esc.rzg.mpg.de
 
-[production]
+[production-centos]
+enc-production-hv-nomad.esc.rzg.mpg.de
+
+[production-suse]
 enc-production-nomad.esc.rzg.mpg.de
diff --git a/deploy/playbook-production-centos.yml b/deploy/playbook-production-centos.yml
new file mode 100644
index 00000000..512f78cb
--- /dev/null
+++ b/deploy/playbook-production-centos.yml
@@ -0,0 +1,23 @@
+---
+
+- hosts: production-centos
+  vars:
+    project_root: /home/nomadapp/gui
+    project_repo: git@gitlab.mpcdf.mpg.de:nomad-lab/encyclopedia-gui.git
+    project_cloned_dir: /home/deploy/encyclopedia-gui-repo-cloned
+
+  tasks:
+  - name: Pull sources from the repository
+    git: repo={{ project_repo }} dest={{ project_cloned_dir }}
+
+  - name: Copy only GUI source files from cloned repo to project directory
+    synchronize: src={{ project_cloned_dir }}/client/ dest={{ project_root}}/
+    delegate_to: "{{ inventory_hostname }}"
+    become: yes
+
+  - name: Change permissions for project directory
+    shell: chown -R nomadapp:nomadapp {{ project_root }}
+    become: yes
+
+  - name: Restart NGINX
+    command: systemctl restart nginx
diff --git a/deploy/playbook-production.yml b/deploy/playbook-production-suse.yml
similarity index 97%
rename from deploy/playbook-production.yml
rename to deploy/playbook-production-suse.yml
index 3c2f10a2..2fbc6d15 100644
--- a/deploy/playbook-production.yml
+++ b/deploy/playbook-production-suse.yml
@@ -1,6 +1,6 @@
 ---
 
-- hosts: production
+- hosts: production-suse
   vars:
     project_root: /home/nomadapp/gui
     project_repo: git@gitlab.mpcdf.mpg.de:nomad-lab/encyclopedia-gui.git
-- 
GitLab