diff --git a/README.md b/README.md index c18c332..74288b0 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ $ ansible-playbook -i hosts update-frontend-prod.yml --key-file="/path/to/key/on ### Updating and redeploying -***Not yet finished*** - *Note: This playbook currently pulls changes from the NYPL's repository, pending completion of our fork* Once new changes have been added to the master branch of the [backend repo]("https://github.com/NYPL/bardo-copyright-db"), run the `update-backend-prod` playbook: diff --git a/roles/cce_backend_prod/tasks/main.yml b/roles/cce_backend_prod/tasks/main.yml index e69de29..f91a2f2 100644 --- a/roles/cce_backend_prod/tasks/main.yml +++ b/roles/cce_backend_prod/tasks/main.yml @@ -0,0 +1,37 @@ +--- +- name: Bring down the app if it is running (ignore error msg) + become: true + ignore_errors: true + shell: "kill $(pgrep -f 'python -m flask run')" + +- name: Pull from GitHub + git: + accept_hostkey: true + force: true + update: true + repo: "{{ backend_git_repo }}" + dest: "{{ backend_project_path }}" + version: "{{ backend_git_branch }}" + +- name: Copy in .env file + copy: + src: "../files/.env" + dest: "{{backend_project_path}}/.env" + +- name: Clear venv if it exists (ignore error msg) + ignore_errors: true + command: "/home/{{backend_user_name}}/.local/bin/pipenv --rm" + args: + chdir: "{{ backend_project_path }}" + +- name: Rebuild venv (ignore error msg) + ignore_errors: true + command: "/home/{{backend_user_name}}/.local/bin/pipenv install" + args: + chdir: "{{ backend_project_path }}" + +# Source: https://ansibledaily.com/execute-detached-process-with-ansible/ & https://stackoverflow.com/a/10908325 +- name: Launch app + shell: "(nohup /home/{{backend_user_name}}/.local/bin/pipenv run python -m flask run /dev/null 2>&1 &)" + args: + chdir: "{{ backend_project_path }}" \ No newline at end of file