diff --git a/local.yml b/local.yml index e71dbf59cb5d036de52dfaf6ed5218650102e2fc..2bef041ba9e032a17af9fcfc66c2a66723e8a791 100644 --- a/local.yml +++ b/local.yml @@ -27,6 +27,7 @@ - python3-venv roles: + - git-clone-or-pull - jupyter-lab - ml-python-packages - misc-applications diff --git a/roles/git-clone-or-pull/files/clone-or-pull.sh b/roles/git-clone-or-pull/files/clone-or-pull.sh new file mode 100755 index 0000000000000000000000000000000000000000..19052a75a00c5b4d33d18c80e8c227e5fbc8b3a2 --- /dev/null +++ b/roles/git-clone-or-pull/files/clone-or-pull.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +GIT_URL="https://code.fbi.h-da.de/pse-ai-at-the-edge/ai-at-the-edge.git" +DIRECTORY_NAME="ai-at-the-edge" +CLONE_DIRECTORY="$HOME/notebooks" + +mkdir -p $CLONE_DIRECTORY +cd $CLONE_DIRECTORY +if test -d "$DIRECTORY_NAME"; then + # directory already exists. Just pull to update + cd $DIRECTORY_NAME + git pull +else + # directory does not exist. Clone the repo + git clone $GIT_URL +fi \ No newline at end of file diff --git a/roles/git-clone-or-pull/tasks/main.yml b/roles/git-clone-or-pull/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..ddf1e73f94d9d812ae7caddf584375e28f051222 --- /dev/null +++ b/roles/git-clone-or-pull/tasks/main.yml @@ -0,0 +1,13 @@ +--- +# roles/git-clone-or-pull + +- name: Copy clone-or-pull script to remote fs + copy: + mode: u=rwx,g=rx,o=rx + src: files/clone-or-pull.sh + dest: /tmp/clone-or-pull.sh + +- name: + become: true + become_user: "{{ target_user }}" + shell: "bash /tmp/clone-or-pull.sh" \ No newline at end of file