Browse Source

Merge pull request #761 from abhishek-sa1/control_plane_tag

Changes for control_plane tags validation
Sujit Jadhav 3 years ago
parent
commit
f5f63a5e8c

+ 0 - 1
control_plane/roles/control_plane_common/tasks/main.yml

@@ -15,7 +15,6 @@
 
 
 - name: Pre-requisite validation
 - name: Pre-requisite validation
   import_tasks: pre_requisite.yml
   import_tasks: pre_requisite.yml
-  tags: init
 
 
 - name: Internet validation
 - name: Internet validation
   import_tasks: internet_validation.yml
   import_tasks: internet_validation.yml

+ 20 - 2
control_plane/roles/control_plane_common/tasks/pre_requisite.yml

@@ -13,29 +13,42 @@
 #  limitations under the License.
 #  limitations under the License.
 ---
 ---
 
 
+- name: Validate skip tags
+  fail:
+    msg: "{{ invalid_skip_tag_msg }}"
+  tags: [ network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
+  when:
+    - '"init" in ansible_skip_tags'
+
 - name: Validate run tags
 - name: Validate run tags
   fail:
   fail:
-    msg: "{{ invalid_tag_msg }}"
-  when: '"init" not in ansible_run_tags'
+    msg: "{{ invalid_run_tag_msg }}"
+  when:
+    - '"init" not in ansible_run_tags'
+    - '"all" not in ansible_run_tags'
   tags: [ init, network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
   tags: [ init, network-device, pxe, awx, network-ib, idrac, monitoring, security, firmware-repo, templates ]
 
 
 - name: Mount Path
 - name: Mount Path
   set_fact:
   set_fact:
     mount_path: "{{ role_path + '/../../..'  }}"
     mount_path: "{{ role_path + '/../../..'  }}"
+  tags: init
     
     
 - name: Collecting ansible python version
 - name: Collecting ansible python version
   shell:
   shell:
     cmd: ansible --version | grep "python version" | cut -d ' ' -f 6
     cmd: ansible --version | grep "python version" | cut -d ' ' -f 6
   register: ansible_python_version
   register: ansible_python_version
   changed_when: false
   changed_when: false
+  tags: init
 
 
 - name: Saving management station os
 - name: Saving management station os
   set_fact:
   set_fact:
     mgmt_os: "{{ ansible_facts['distribution'] | lower }}"
     mgmt_os: "{{ ansible_facts['distribution'] | lower }}"
+  tags: init
 
 
 - name: Verify the ansible and python versions installed
 - name: Verify the ansible and python versions installed
   fail:
   fail:
     msg: "{{ ansible_python_version_status }}"
     msg: "{{ ansible_python_version_status }}"
+  tags: init
   when:
   when:
     - ansible_python_version.stdout != python_version_leap
     - ansible_python_version.stdout != python_version_leap
     - ansible_python_version.stdout != python_version_support
     - ansible_python_version.stdout != python_version_support
@@ -44,6 +57,7 @@
   stat:
   stat:
     path: "{{ default_ansible_config_file_path }}"
     path: "{{ default_ansible_config_file_path }}"
   register: file_exists
   register: file_exists
+  tags: init
 
 
 - name: Set omnia.log file
 - name: Set omnia.log file
   replace:
   replace:
@@ -51,6 +65,7 @@
     regexp: '#log_path = /var/log/ansible.log'
     regexp: '#log_path = /var/log/ansible.log'
     replace: 'log_path = /var/log/omnia.log'
     replace: 'log_path = /var/log/omnia.log'
   when: file_exists.stat.exists
   when: file_exists.stat.exists
+  tags: init
 
 
 - name: Check OS support
 - name: Check OS support
   assert:
   assert:
@@ -61,6 +76,7 @@
     fail_msg: "{{ fail_os_status }}"
     fail_msg: "{{ fail_os_status }}"
     success_msg: "{{ success_os_status }}"
     success_msg: "{{ success_os_status }}"
   register: os_value
   register: os_value
+  tags: init
 
 
 - block:
 - block:
     - name: Fetch SElinux mode
     - name: Fetch SElinux mode
@@ -80,6 +96,7 @@
         msg: "{{ selinux_status }}"
         msg: "{{ selinux_status }}"
       when: '"SELinux status: enabled" in sestatus_current.stdout_lines'
       when: '"SELinux status: enabled" in sestatus_current.stdout_lines'
       register: selinux_value
       register: selinux_value
+  tags: init
   when:
   when:
     - ( mgmt_os == os_supported_centos ) and ( ansible_distribution_version >= os_supported_centos_version ) or
     - ( mgmt_os == os_supported_centos ) and ( ansible_distribution_version >= os_supported_centos_version ) or
       ( mgmt_os == os_supported_rocky ) and ( ansible_distribution_version >= os_supported_rocky_version )
       ( mgmt_os == os_supported_rocky ) and ( ansible_distribution_version >= os_supported_rocky_version )
@@ -89,3 +106,4 @@
     name: firewalld
     name: firewalld
     state: started
     state: started
     enabled: yes
     enabled: yes
+  tags: init

+ 2 - 1
control_plane/roles/control_plane_common/vars/main.yml

@@ -71,7 +71,8 @@ selinux_status: "SElinux is not disabled. Disable it in /etc/sysconfig/selinux a
 ansible_python_version_status: "For CentOS 8.3, python bindings of firewalld, dnf, selinux are not available if python is installed from source and not from dnf. So please make sure python3.6 is installed using dnf. And ansible uses the python version 3.6 installed using dnf"
 ansible_python_version_status: "For CentOS 8.3, python bindings of firewalld, dnf, selinux are not available if python is installed from source and not from dnf. So please make sure python3.6 is installed using dnf. And ansible uses the python version 3.6 installed using dnf"
 python_version_support: '3.6.8'
 python_version_support: '3.6.8'
 default_ansible_config_file_path: /etc/ansible/ansible.cfg
 default_ansible_config_file_path: /etc/ansible/ansible.cfg
-invalid_tag_msg: "Failed. init tag can't be skipped"
+invalid_run_tag_msg: "Failed. init tag should be used with run tags"
+invalid_skip_tag_msg: "Failed. init tag can't be used with skip tags"
 
 
 # Usage: verify_login_inputs.yml
 # Usage: verify_login_inputs.yml
 login_vars_filename: "input_params/login_vars.yml"
 login_vars_filename: "input_params/login_vars.yml"