Explorar o código

treat cmdline need_* properly; add patch & hotfix checks; defaults

Grega Bremec %!s(int64=2) %!d(string=hai) anos
pai
achega
49a80597aa

+ 1 - 0
ansible.cfg

@@ -9,3 +9,4 @@ ask_pass = no
 become = no
 become_method = sudo
 become_askpass = no
+

+ 6 - 1
inventory.yml

@@ -9,10 +9,13 @@ all:
     bastion.lab.example.com:
       ansible_user: root
   vars:
-    # OpenShift and RHSSO versions.
+    # OpenShift versions.
     ocp_maj: "4.10"
     ocp_z: "4.10.3"
+    # Various RHSSO versions.
     sso_z: "7.6.0"
+    sso_p: "7.6.1"
+    sso_f: "4361"
 
     # These are the tools we need, some also need to be downloaded.
     tools:
@@ -43,4 +46,6 @@ all:
 
     # Whether we will use a standalone RHSSO ZIP or not (only used in check-env).
     need_sso_zip: yes
+    need_sso_patch: yes
+    need_sso_hotfix: yes
 ...

+ 10 - 0
roles/check-env/defaults/main.yml

@@ -0,0 +1,10 @@
+---
+# Provide defaults to simplify conditionals.
+need_sso_zip: yes
+need_sso_patch: yes
+need_sso_hotfix: yes
+# These need to default to something, too.
+sso_z: "7.6.0"
+sso_p: "7.6.1"
+sso_f: "4361"
+...

+ 36 - 2
roles/check-env/tasks/main.yml

@@ -8,6 +8,10 @@
 #  clusters:
 #   just a simple list of clusters to check
 #
+#  need_sso_zip
+#  need_sso_patch
+#  need_sso_hotfix
+#
 - name: Check for tools
   file:
     path: "{{ tools[item].final_name }}"
@@ -63,11 +67,41 @@
   stat:
     path: "{{ ansible_facts['user_dir'] }}/Downloads/rh-sso-{{ sso_z }}-server-dist.zip"
   register: sso_zip
-  when: need_sso_zip
+  when: need_sso_zip|bool
+
+- assert:
+    that: sso_zip.stat.exists
+    fail_msg: "ERROR: RHSSO ZIP not downloaded! Please go to section 'Before You Begin' in your book."
+    success_msg: "OK: Found RHSSO ZIP file."
+  when: need_sso_zip|bool
+
+- name: Check RHSSO patch is there
+  stat:
+    path: "{{ ansible_facts['user_dir'] }}/Downloads/rh-sso-{{ sso_p }}-patch.zip"
+  register: sso_patch
+  when: need_sso_zip|bool and need_sso_patch|bool
+
+- name: Check RHSSO hotfix is there
+  stat:
+    path: "{{ ansible_facts['user_dir'] }}/Downloads/rhsso-{{ sso_f }}.zip"
+  register: sso_hotfix
+  when: need_sso_zip|bool and need_sso_hotfix|bool
 
 - assert:
     that: sso_zip.stat.exists
     fail_msg: "ERROR: RHSSO ZIP not downloaded! Please go to section 'Before You Begin' in your book."
     success_msg: "OK: Found RHSSO ZIP file."
-  when: need_sso_zip
+  when: need_sso_zip|bool
+
+- assert:
+    that: sso_patch.stat.exists
+    fail_msg: "ERROR: RHSSO patch not downloaded! Please go to section 'Before You Begin' in your book."
+    success_msg: "OK: Found RHSSO patch file."
+  when: need_sso_zip|bool and need_sso_patch|bool
+
+- assert:
+    that: sso_hotfix.stat.exists
+    fail_msg: "ERROR: RHSSO hotfix not downloaded! Please go to section 'Before You Begin' in your book."
+    success_msg: "OK: Found RHSSO hotfix file."
+  when: need_sso_zip|bool and need_sso_hotfix|bool
 ...

+ 3 - 0
roles/check-env/vars/main.yml

@@ -3,6 +3,9 @@
 # 
 #  - tools
 #  - clusters
+#  - need_sso_zip
+#  - need_sso_patch
+#  - need_sso_hotfix
 #
 # consult the role tasks file for an explanation
 ...