]> git.immae.eu Git - github/fretlink/ansible-clever.git/commitdiff
deploy: check "up-to-date" error to succeeded if last commit is OK 33/head
authorPaul Bonaud <paul.bonaud@fretlink.com>
Wed, 16 Jan 2019 07:58:43 +0000 (08:58 +0100)
committerPaul Bonaud <paul.bonaud@fretlink.com>
Wed, 16 Jan 2019 13:41:44 +0000 (14:41 +0100)
tasks/deploy.yml
vars/main.yml

index 0ed97f87d29e70e7d4c658fa253a4463573e6dd1..b394e55ba85fc7e10ab0c4d78202edc92f954090 100644 (file)
     - clever_deploy is failed
     - clever_deploy.stderr is defined
 
+- shell: clever activity
+  args:
+    chdir: "{{ clever_app_root }}"
+  environment:
+    CONFIGURATION_FILE: "{{ clever_login_file }}"
+  changed_when: false
+  register: clever_activity_result
+
+- debug:
+    var: clever_activity_result.stdout_lines
+
+- shell: git show -q --format=format:%H HEAD
+  args:
+    chdir: "{{ clever_app_root }}"
+  changed_when: false
+  register: current_commit_sha
+
+# ####
+# Expects all configuration to be located in the project's repository.
+# Making a git commit bound to the same *configuration* and *executable* version.
+# ##
+- name: Fail if current commit is not the last deployed one
+  fail:
+    msg: "The clever deployment failed! Please check latest deploy activity logs above."
+  when:
+    - clever_deploy is failed
+    - clever_deploy.stderr is defined
+    - clever_deploy.stderr is search("application is up-to-date")
+    - clever_activity_valid_deploy_keyword in clever_activity_result.stdout_lines[-1]
+    - current_commit_sha.stdout_lines[-1] in clever_activity_result.stdout_lines[-1]
+
 - name: Fail on deployment errors
   fail:
     msg: "The clever deployment failed! Please check logs above."
-  when: clever_deploy is failed
+  when:
+    - clever_deploy is failed
+    - clever_deploy.stderr is defined
+    - clever_deploy.stderr is not search("application is up-to-date")
index adeac01b446b6edcf51b341028a1efa12c780f0a..a6086fef27bf6c0c2f7b71ee00eceef42596926c 100644 (file)
@@ -7,3 +7,5 @@ clever_base_env:
   CC_RUN_COMMAND:     "~/.local/bin/{{ clever_haskell_entry_point }}"
   ENABLE_METRICS:     "{{ clever_metrics | lower }}"
   PORT:               "8080"
+
+clever_activity_valid_deploy_keyword: " OK "