#  Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
---

# Testcase OMNIA_DIO_US_DVC_TC_001
# Execute common role in management station with os installed centos 7.9
- name: OMNIA_DIO_US_DVC_TC_001
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Check OS support
      fail:
        msg: "{{ os_status }}"
      when: not(ansible_distribution == os_name and ansible_distribution_version >= os_version)
      tags: TC_001

    - name: Delete docker volume
      docker_volume:
        name: "{{ docker_volume_name }}"
        state: absent
      tags: TC_001

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
          vars:
            input_config_filename: "{{ test_input_config_filename }}"
      tags: TC_001

    - name: Fetch package installed
      package_facts:
        manager: auto
      tags: TC_001,VERIFY_001

    - name: Verify all required packages is installed
      assert:
        that: "'{{ item }}' in ansible_facts.packages"
        success_msg: "{{ install_package_success_msg }}"
        fail_msg: "{{ install_package_fail_msg }}"
      when: "'python-docker' not in item"
      with_items: "{{ common_packages }}"
      tags: TC_001,VERIFY_001

    - name: Verify python-docker-py package is installed
      assert:
        that: "'python-docker-py' in ansible_facts.packages"
        success_msg: "{{ install_package_success_msg }}"
        fail_msg: "{{ install_package_fail_msg }}"
      tags: TC_001,VERIFY_001

    - name: Fetching docker volume info
      docker_volume_info:
        name: "{{ docker_volume_name }}"
      register: docker_volume_status
      tags: TC_001,VERIFY_001

    - name: Validate docker volume
      assert:
        that: docker_volume_status.exists
        fail_msg: "{{ docker_volume_fail_msg }}"
        success_msg: "{{ docker_volume_success_msg }}"
      tags: TC_001,VERIFY_001

    - name: Check input config file is encrypted
      command: cat {{ test_input_config_filename }}
      changed_when: false
      register: config_content
      tags: TC_001,VERIFY_001

    - name: Validate input config file is encypted or not
      assert:
        that: "'$ANSIBLE_VAULT;' in config_content.stdout"
        fail_msg: "{{ input_config_fail_msg }}"
        success_msg: "{{ input_config_success_msg }}"
      tags: TC_001,VERIFY_001

# Testcase OMNIA_DIO_US_DVC_TC_002
# Execute common role in management station with docker volume omnia-storage already present
- name: OMNIA_DIO_US_DVC_TC_002
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
          vars:
            input_config_filename: "{{ test_input_config_filename }}"
      tags: TC_002

    - name: Fetch package installed
      package_facts:
        manager: auto
      tags: TC_002,VERIFY_002

    - name: Verify all required packages is installed
      assert:
        that: "'{{ item }}' in ansible_facts.packages"
        success_msg: "{{ install_package_success_msg }}"
        fail_msg: "{{ install_package_fail_msg }}"
      when: "'python-docker' not in item"
      with_items: "{{ common_packages }}"
      tags: TC_002,VERIFY_002

    - name: Verify python-docker-py package is installed
      assert:
        that: "'python-docker-py' in ansible_facts.packages"
        success_msg: "{{ install_package_success_msg }}"
        fail_msg: "{{ install_package_fail_msg }}"
      tags: TC_002,VERIFY_002

    - name: Fetching docker volume info
      docker_volume_info:
        name: "{{ docker_volume_name }}"
      register: docker_volume_status
      tags: TC_002,VERIFY_002

    - name: Validate docker volume
      assert:
        that: docker_volume_status.exists
        fail_msg: "{{ docker_volume_fail_msg }}"
        success_msg: "{{ docker_volume_success_msg }}"
      tags: TC_002,VERIFY_002

    - name: Check input config file is encrypted
      command: cat {{ test_input_config_filename }}
      changed_when: false
      register: config_content
      tags: TC_002,VERIFY_002

    - name: Validate input config file is encypted or not
      assert:
        that: "'$ANSIBLE_VAULT;' in config_content.stdout"
        fail_msg: "{{ input_config_fail_msg }}"
        success_msg: "{{ input_config_success_msg }}"
      tags: TC_002,VERIFY_002

# Testcase OMNIA_DIO_US_DVC_TC_003
# Execute common role in management station with os installed different than centos 7.9
- name: OMNIA_DIO_US_DVC_TC_003
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
          vars:
            input_config_filename: "{{ test_input_config_filename }}"
            ansible_distribution_version: "{{ centos_version }}"

      rescue:
        - name: Validate OS check failure message
          assert:
            that: os_status in os_value.msg
            success_msg: "{{ os_check_success_msg }}"
            fail_msg: "{{ os_check_fail_msg }}"
      tags: TC_003

# Testcase OMNIA_DIO_US_DVC_TC_004
# Execute common role in management station without internet connectivity
- name: OMNIA_DIO_US_DVC_TC_004
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Down internet connectivity
      lineinfile:
        path: /etc/hosts
        line: "172.16.0.5 github.com"
        state: present
        backup: yes
      tags: TC_004

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
          vars:
            input_config_filename: "{{ test_input_config_filename }}"

      rescue:
        - name: Validate internet connectivity failure message
          assert:
            that: internet_status in internet_value.msg
            success_msg: "{{ internet_check_success_msg }}"
            fail_msg: "{{ internet_check_fail_msg }}"
      tags: TC_004

    - name: Up internet connectivity
      lineinfile:
        path: /etc/hosts
        line: "172.16.0.5 github.com"
        state: absent
      tags: TC_004

# Testcase OMNIA_DIO_US_DVC_TC_005
# Execute common role in management station with different user than root
- name: OMNIA_DIO_US_DVC_TC_005
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
  tasks:
    - name: Create temp user
      user:
        name: temp
      tags: TC_005

    - block:
        - name: Execute playbook with different user
          command: ansible-playbook ../appliance.yml --become-user=temp -e "input_config_filename=test/input_config_test.yml"
          register: temp_user_output

      rescue:
        - name: Validate the different user execution failure message
          assert:
            that:
              - '"FAILED" in temp_user_output.stdout'
              - '"This command has to be run under the root user" in temp_user_output.stdout'
            success_msg: "{{ different_user_check_success_msg }}"
            fail_msg: "{{ different_user_check_fail_msg }}"
      tags: TC_005

    - name: Remove temp user
      user:
        name: temp
        state: absent
        remove: yes
      tags: TC_005

# Testcase OMNIA_DIO_US_DVC_TC_006
# Execute common role in management station with selinux enabled.
- name: OMNIA_DIO_US_DVC_TC_006
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Enable selinux
      selinux:
        policy: targeted
        state: enforcing
      when: ansible_selinux.status == "disabled"
      tags: TC_006

    - name: Reboot localhost
      command: reboot
      when: ansible_selinux.status == "disabled"
      tags: TC_006

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
          vars:
            input_config_filename: "{{ test_input_config_filename }}"

      rescue:
        - name: Validate selinux failure message
          assert:
            that: selinux_status in selinux_value.msg
            success_msg: "{{ selinux_check_success_msg }}"
            fail_msg: "{{ selinux_check_fail_msg  }}"
      tags: TC_006

    - name: Disable selinux
      selinux:
        state: disabled
      tags: TC_006

# Testcase OMNIA_DIO_US_DVC_TC_007
# Execute common role in management station with all input paramter as empty
- name: OMNIA_DIO_US_DVC_TC_007
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ empty_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_007

# Testcase OMNIA_DIO_US_DVC_TC_008
# Execute common role in management station with provision_password as empty
- name: OMNIA_DIO_US_DVC_TC_008
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_008

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_008

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_008

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_008

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_008

# Testcase OMNIA_DIO_US_DVC_TC_009
# Execute common role in management station with awx_password as empty
- name: OMNIA_DIO_US_DVC_TC_009
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_009

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_009

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_009

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_009

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_009

# Testcase OMNIA_DIO_US_DVC_TC_010
# Execute common role in management station with iso_file_path as empty
- name: OMNIA_DIO_US_DVC_TC_010
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_010

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_010

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_010

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_010

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_010

# Testcase OMNIA_DIO_US_DVC_TC_011
# Execute common role in management station with provision_password of more than 31 characters
- name: OMNIA_DIO_US_DVC_TC_011
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_011

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_011

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ long_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_011

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_msg_provision_password in cobbler_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_011

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_011

# Testcase OMNIA_DIO_US_DVC_TC_012
# Execute common role in management station with provision_password as string contains white spaces
- name: OMNIA_DIO_US_DVC_TC_012
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_012

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_012

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ white_space_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_012

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: success_msg_provision_password in cobbler_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_012

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_012

# Testcase OMNIA_DIO_US_DVC_TC_013
# Execute common role in management station with provision_password as string contains characters like '/' and '-'
- name: OMNIA_DIO_US_DVC_TC_013
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_013

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_013

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ special_character_password1 }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_013

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_msg_provision_password in cobbler_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_013

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_013

# Testcase OMNIA_DIO_US_DVC_TC_014
# Execute common role in management station with provision_password as string contains special characters other than '-', '/'
- name: OMNIA_DIO_US_DVC_TC_014
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_014

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_014

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ special_character_password2 }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_014

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: success_msg_provision_password in cobbler_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_014

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_014

# Testcase OMNIA_DIO_US_DVC_TC_015
# Execute common role in management station with awx_password of more than 31 characters
- name: OMNIA_DIO_US_DVC_TC_015
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_015

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_015

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ long_password }}\"" }
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_015

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_msg_awx_password in awx_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_015

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_015

# Testcase OMNIA_DIO_US_DVC_TC_016
# Execute common role in management station with awx_password as string contains white spaces
- name: OMNIA_DIO_US_DVC_TC_016
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_016

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_016

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ white_space_password }}\"" }
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_016

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: success_msg_awx_password in awx_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_016

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_016

# Testcase OMNIA_DIO_US_DVC_TC_017
# Execute common role in management station with awx_password as string contains characters like '/' and '-'
- name: OMNIA_DIO_US_DVC_TC_017
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_017

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_017

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ special_character_password1 }}\"" }
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_017

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_msg_awx_password in awx_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_017

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_017

# Testcase OMNIA_DIO_US_DVC_TC_018
# Execute common role in management station with awx_password as string contains special characters other than '-', '/'
- name: OMNIA_DIO_US_DVC_TC_018
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_018

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_018

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ special_character_password2 }}\"" }
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_018

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: success_msg_awx_password in awx_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_018

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_018

# Testcase OMNIA_DIO_US_DVC_TC_019
# Execute common role in management station with valid iso_file_path
- name: OMNIA_DIO_US_DVC_TC_019
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_019

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_019

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_019

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: result_path_iso_file.stat.exists == true
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_019

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_019

# Testcase OMNIA_DIO_US_DVC_TC_020
# Execute common role in management station with wrong iso_file_path
- name: OMNIA_DIO_US_DVC_TC_020
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_020

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_020

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ wrong_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_020

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Check log file
          command: tail /var/log/omnia.log
          register: iso_fail_log_check
          changed_when: false
            
        - name: Validate error
          assert:
            that: invalid_iso_file_path in iso_fail_log_check.stdout
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_020

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_020

# Testcase OMNIA_DIO_US_DVC_TC_021
# Execute common role in management station with dhcp_start_ip_range as empty
- name: OMNIA_DIO_US_DVC_TC_021
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_021

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_021

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_021

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_021

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_021

# Testcase OMNIA_DIO_US_DVC_TC_022
# Execute common role in management station with dhcp_end_ip_range as empty
- name: OMNIA_DIO_US_DVC_TC_022
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_022

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_022

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
      tags: TC_022

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_022

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_022

# Testcase OMNIA_DIO_US_DVC_TC_023
# Execute common role in management station with mapping_file_path provided
- name: OMNIA_DIO_US_DVC_TC_023
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_023

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_023

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "mapping_file_path: \"\"", replace: "mapping_file_path: \"{{ valid_mapping_file_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_023

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Check log file
          command: tail -100 /var/log/omnia.log
          register: mapping_success_log_check
          changed_when: false
          
        - name: Validate success message
          assert:
            that: success_mapping_file in mapping_success_log_check.stdout
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_023

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_023

# Testcase OMNIA_DIO_US_DVC_TC_024
# Execute common role in management station with awx_password of 30 characters
- name: OMNIA_DIO_US_DVC_TC_024
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_024

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_024

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ max_length_password }}\"" }
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_024

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: success_msg_awx_password in awx_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_024

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_024

# Testcase OMNIA_DIO_US_DVC_TC_025
# Execute common role in management station with provision_password of 30 characters
- name: OMNIA_DIO_US_DVC_TC_025
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_025

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_025

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ max_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_025

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      always:
        - name: Validate success message
          assert:
            that: success_msg_provision_password in cobbler_password_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_025

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_025

# Testcase OMNIA_DIO_US_DVC_TC_026
# Execute common role in management station with hpc_nic and public_nic as same value
- name: OMNIA_DIO_US_DVC_TC_026
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_026

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_026

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
        - { regexp: "hpc_nic: \"em1\"", replace: "hpc_nic: \"em2\"" }
      tags: TC_026

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_msg_hpc_nic in hpc_nic_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_026

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_026

# Testcase OMNIA_DIO_US_DVC_TC_027
# Execute common role in management station with hpc_nic as empty
- name: OMNIA_DIO_US_DVC_TC_027
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_027

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_027

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
        - { regexp: "hpc_nic: \"em1\"", replace: "hpc_nic: \"\"" }
      tags: TC_027

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_027

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_027

# Testcase OMNIA_DIO_US_DVC_TC_028
# Execute common role in management station with public_nic as empty
- name: OMNIA_DIO_US_DVC_TC_028
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_028

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_028

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
        - { regexp: "public_nic: \"em2\"", replace: "public_nic: \"\"" }
      tags: TC_028

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: input_config_failure_msg in input_config_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_028

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_028

# Testcase OMNIA_DIO_US_DVC_TC_029
# Execute common role in management station with public_nic not present in device
- name: OMNIA_DIO_US_DVC_TC_029
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_029

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_029

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
        - { regexp: "public_nic: \"em2\"", replace: "public_nic: \"em5\"" }
      tags: TC_029

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_hpc_ip in public_ip_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_029

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_029

# Testcase OMNIA_DIO_US_DVC_TC_030
# Execute common role in management station with hpc_nic not present in device
- name: OMNIA_DIO_US_DVC_TC_030
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_030

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_030

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
        - { regexp: "hpc_nic: \"em1\"", replace: "hpc_nic: \"em5\"" }
      tags: TC_030

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_hpc_ip in hpc_ip_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_030

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_030

# Testcase OMNIA_DIO_US_DVC_TC_031
# Execute common role with dhcp_start_ip_range in wrong ip range
- name: OMNIA_DIO_US_DVC_TC_031
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_031

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_031

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ invalid_dhcp_ip }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_031

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_dhcp_range in dhcp_start_ip_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_031

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_031

# Testcase OMNIA_DIO_US_DVC_TC_032
# Execute common role with dhcp_start_ip_range in wrong format
- name: OMNIA_DIO_US_DVC_TC_032
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_032

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_032

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ wrong_dhcp_ip }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ valid_dhcp_end_range }}\"" }
      tags: TC_032

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_dhcp_range in dhcp_start_ip_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_032

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_032

# Testcase OMNIA_DIO_US_DVC_TC_033
#Execute common role with dhcp_end_ip_range in wrong format
- name: OMNIA_DIO_US_DVC_TC_033
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_033

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_033

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ wrong_dhcp_ip }}\"" }
      tags: TC_033

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_dhcp_range in dhcp_start_ip_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_033

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_033

# Testcase OMNIA_DIO_US_DVC_TC_034
#Execute common role with dhcp_end_ip_range in wrong ip range
- name: OMNIA_DIO_US_DVC_TC_034
  hosts: localhost
  connection: local
  gather_subset:
    - 'min'
  vars_files:
    - test_vars/test_common_vars.yml
    - ../roles/common/vars/main.yml
  tasks:
    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_034

    - name: Copy "{{ empty_input_config_filename }}" to new file
      copy:
        src: "{{ empty_input_config_filename }}"
        dest: "{{ new_input_config_filename }}"
      tags: TC_034

    - name: Edit "{{ new_input_config_filename }}"
      replace:
        path: "{{ new_input_config_filename }}"
        regexp: "{{ item.regexp }}"
        replace: "{{ item.replace }}"
      with_items:
        - { regexp: "provision_password: \"\"", replace: "provision_password: \"{{ min_length_password }}\"" }
        - { regexp: "awx_password: \"\"", replace: "awx_password: \"{{ min_length_password }}\"" }
        - { regexp: "iso_file_path: \"\"", replace: "iso_file_path: \"{{ valid_iso_path }}\"" }
        - { regexp: "dhcp_start_ip_range: \"\"", replace: "dhcp_start_ip_range: \"{{ valid_dhcp_start_range }}\"" }
        - { regexp: "dhcp_end_ip_range: \"\"", replace: "dhcp_end_ip_range: \"{{ invalid_dhcp_ip }}\"" }
      tags: TC_034

    - block:
        - name: Call common role
          include_role:
            name: ../roles/common
            tasks_from: "{{ password_config_file }}"
          vars:
            input_config_filename: "{{ new_input_config_filename }}"
      rescue:
        - name: Validate error
          assert:
            that: fail_dhcp_range in dhcp_start_ip_check.msg
            success_msg: "{{ input_config_check_success_msg }}"
            fail_msg: "{{ input_config_check_fail_msg }}"
      tags: TC_034

    - name: Delete "{{ new_input_config_filename }}"
      file:
        path: "{{ new_input_config_filename }}"
        state: absent
      tags: TC_034