From 36dccf203358936dcc739f04bd339866e2329d03 Mon Sep 17 00:00:00 2001
From: Sven Marcus <s.marcus@outlook.de>
Date: Wed, 18 Nov 2020 17:15:37 +0100
Subject: [PATCH] Update jupyter docker spawner image from gitlab ci

---
 .gitlab-ci.yml                      | 24 ++++++++++++++++++++++++
 ansible/hosts.cfg                   |  2 +-
 ansible/playbook_jupyter_update.yml |  2 +-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ee018ed43..62698b271 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -516,6 +516,30 @@ vf_to_phoenix:
           - y0054816
 
 ###############################################################################
+vf_wheel_to_jupyterhub:
+  stage: deploy
+
+  needs: ["gcc_9_python", "gcc_9_unit_tests", "gcc_9_python_bindings_test"]
+
+  variables:
+    HOST: "finrod.irmb.bau.tu-bs.de"
+    SSH_KEY: "$SSH_PRIVATE_KEY_JUPYTER_HOST_AT_FINROD"
+    REMOTE_USER: "jupyter_host"
+
+  before_script:
+    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
+    - apt-get install -y rsync
+    - mkdir -p ~/.ssh
+    - chmod 700 ~/.ssh
+    - eval $(ssh-agent -s)
+    - echo "$SSH_KEY" | tr -d '\r' | ssh-add -
+    - echo $SSH_KEY >> ansible/private_key
+    - ssh-keyscan -t rsa $HOST >> ~/.ssh/known_hosts
+    - pip3 install ansible
+
+  script:
+    - ansible-playbook -i ansible/hosts.cfg -u $REMOTE_USER ansible/playbook_jupyter_update.yml
+
 cppcheck_to_elladan:
   extends: .deploy_template
   stage: deploy
diff --git a/ansible/hosts.cfg b/ansible/hosts.cfg
index 160b8a196..0f340834c 100644
--- a/ansible/hosts.cfg
+++ b/ansible/hosts.cfg
@@ -7,4 +7,4 @@ elladan.irmb.bau.tu-bs.de
 [gitlab_ci_deploy_gcov]
 elladan.irmb.bau.tu-bs.de
 [gitlab_ci_deploy_wheel]
-finrod.irmb.bau.tu-bs.de
\ No newline at end of file
+finrod.irmb.bau.tu-bs.de ansible_ssh_private_key_file=~/private_key ansible_become_password="{{ lookup('env', 'ANSIBLE_JUPYTER_HOST_BECOME_PASSWORD') }}"
\ No newline at end of file
diff --git a/ansible/playbook_jupyter_update.yml b/ansible/playbook_jupyter_update.yml
index 4e5f6a9c5..61d6c95af 100644
--- a/ansible/playbook_jupyter_update.yml
+++ b/ansible/playbook_jupyter_update.yml
@@ -1,4 +1,4 @@
-- hosts: local
+- hosts: gitlab_ci_deploy_wheel
   vars:
     host_home: "/home/{{ lookup('env', 'jupyter_host') }}"
 
-- 
GitLab