Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: unable to set IscsiDev1ConXVlanID #682

Open
sistarers opened this issue Jun 14, 2024 · 1 comment
Open

[BUG]: unable to set IscsiDev1ConXVlanID #682

sistarers opened this issue Jun 14, 2024 · 1 comment
Labels
needs-triage Issue requires triage. type/bug Something isn't working

Comments

@sistarers
Copy link

Bug Description

See #648 for additional details. The same ansible controller, version, dellemc.ome collection etc is now unable to set the IscsiDev1ConXVlanID value.

ansible [core 2.14.14]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/ncraf/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /home/ncraf/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.18 (main, Jan 24 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True

Component or Module Name

dellemc.openmanage.idrac_bios:

Ansible Version

Ansible 2.14.14

Python Version

Python 3.9.18

iDRAC/OME/OME-M version

iDRAC: 7.00.00.171, BIOS: 2.9.4

iDRAC: 7.10.30.05, BIOS: 2.1.5

Operating System

N/A but O/S will eventually be esxi 8.x or 7.x: this setting is required in order for the blade to find it's boot disk via iSCSI so the O/S can be installed

Playbook Used

will upload in subsequent post

Logs

[UP - Set BIOS to default settings using specific A/V pairs MX760s] *****************************
Wednesday 12 June 2024 19:51:26 +0000 (0:00:00.063) 0:00:03.695 ********
Wednesday 12 June 2024 19:51:26 +0000 (0:00:00.063) 0:00:03.694 ********
fatal: [cmc_2Y5MW04_blade1-9W5MW04 -> localhost]: FAILED! => {"changed": false, "msg": "HTTP Error 400 on PATCH request to 'https://10.200.4.166/redfish/v1/Systems/System.Embedded.1/Bios/Settings', extended message: 'Unable to set the object properties because an incorrect object value is entered.'"}

TASK [UP - Set BIOS to default settings using specific A/V pairs MX740s] *****************************
Wednesday 12 June 2024 19:51:29 +0000 (0:00:03.884) 0:00:07.579 ********
Wednesday 12 June 2024 19:51:29 +0000 (0:00:03.884) 0:00:07.578 ********
fatal: [cmc_CP40PZ3_blade2-D2NK243 -> localhost]: FAILED! => {"changed": false, "msg": "HTTP Error 400 on PATCH request to 'https://10.200.4.209/redfish/v1/Systems/System.Embedded.1/Bios/Settings', extended message: 'Unable to set the object properties because an incorrect object value is entered.'"}

Steps to Reproduce

run playbook on different platforms of mx740c and mx760c blades

Expected Behavior

vlan integer value is set per the playbook either by variable or by hard coded value in playbook

Actual Behavior

error above occurs

Screenshots

No response

Additional Information

No response

@sistarers sistarers added needs-triage Issue requires triage. type/bug Something isn't working labels Jun 14, 2024
@sistarers
Copy link
Author

sistarers commented Jun 14, 2024

error(s) below, I initiated the playbook with the following command. If the eventvlan variable in the playbook is set using -- eventvlan: anyInteger an the -e eventvlan=anyInteger is not passed then the playbook executes successfully.

ansible-playbook idracup.yml -i labbladestest.hosts -l test_blades02,localhost -e "month=06 eventname=jmnautoevent91 eventvlan=3015" --tags netapp,config_bios

TASK [CONFIGURE unique iSCSI attributes on blade BIOS OME MX740c's] *****************************
Friday 14 June 2024  19:50:15 +0000 (0:00:00.048)       0:00:07.531 *********** 
Friday 14 June 2024  19:50:15 +0000 (0:00:00.048)       0:00:07.531 *********** 
fatal: [cmc_CP40PZ3_blade2-D2NK243]: FAILED! => {"changed": false, "error_info": {"error": {"@Message.ExtendedInfo": [{"Message": "The value 'integer' for the property IscsiDev1Con1VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con1VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con1VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}, {"Message": "The value 'integer' for the property IscsiDev1Con2VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con2VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con2VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}, {"Message": "The value 'integer' for the property IscsiDev1Con1VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con1VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con1VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}, {"Message": "The value 'integer' for the property IscsiDev1Con2VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con2VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con2VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}], "code": "Base.1.12.GeneralError", "message": "A general error has occurred. See ExtendedInfo for more information"}}, "msg": "HTTP Error 400: Bad Request"}

TASK [print unique_bios iscsi attributes register] **********************************************
Friday 14 June 2024  19:50:18 +0000 (0:00:03.524)       0:00:11.056 *********** 
Friday 14 June 2024  19:50:18 +0000 (0:00:03.524)       0:00:11.055 *********** 

TASK [CONFIGURE unique iSCSI attributes on blade BIOS OME MX760c's] *****************************
Friday 14 June 2024  19:50:18 +0000 (0:00:00.036)       0:00:11.092 *********** 
Friday 14 June 2024  19:50:18 +0000 (0:00:00.036)       0:00:11.092 *********** 
fatal: [cmc_2Y5MW04_blade1-9W5MW04]: FAILED! => {"changed": false, "error_info": {"error": {"@Message.ExtendedInfo": [{"Message": "The value 'integer' for the property IscsiDev1Con1VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con1VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con1VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}, {"Message": "The value 'integer' for the property IscsiDev1Con2VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con2VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con2VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}, {"Message": "The value 'integer' for the property IscsiDev1Con1VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con1VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con1VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}, {"Message": "The value 'integer' for the property IscsiDev1Con2VlanId is of a different type than the property can accept.", "MessageArgs": ["integer", "IscsiDev1Con2VlanId"], "[email protected]": 2, "MessageId": "Base.1.12.PropertyValueTypeError", "RelatedProperties": ["#/Attributes/IscsiDev1Con2VlanId"], "[email protected]": 1, "Resolution": "Correct the value for the property in the request body and resubmit the request if the operation failed.", "Severity": "Warning"}], "code": "Base.1.12.GeneralError", "message": "A general error has occurred. See ExtendedInfo for more information"}}, "msg": "HTTP Error 400: Bad Request"}

###########################################################################
# © Copyright 2024 - 2030, Circadence Corporation and Network Excellence. #
###########################################################################

---
- name: poll NetApp for event SVM info
  hosts: localhost
  # connection: local
  gather_facts: false
  collections:
    - netapp.ontap
  vars:
    login: &netapp_login
      hostname: "10.90.10.20"
      username: "rsistare.api"
      password: "Password1!"
      https: true
      validate_certs: false
    parent_int: a0a
    eventname: jmnautoevent01

  tasks:
  # - name: add netapp-lib
  #   ansible.builtin.shell: pip3.9 install netapp-lib
  #   tags:
  #     - netapp

  - name: print original event name
    debug:
      msg: 
        - "original event name {{ eventname }}"
    tags:
      - list
      - netapp

  - name: check event name {{ eventname }} for unwanted characters
    set_fact:
      chkd_eventname: "{{ eventname | regex_replace('[-!@#$%^&*()_+~`/?.>,<|\\[\\]{}]','_') }}"
    tags:
      - list
      - netapp

  - name: print new event name
    debug:
      msg: 
        - "accepted event name {{ chkd_eventname }}"
    tags:
      - list
      - netapp

  - name: Get NetApp iscsi target alias
    netapp.ontap.na_ontap_command:
      <<: *netapp_login
      use_rest: never
      command: "iscsi show -target-alias svm_{{ chkd_eventname }}_auto -fields target-name"
      return_dict: true
      exclude_lines: 'server'
      include_lines: 'iqn.'
    register: na_output
    tags:
      - netapp

  # - name: Print iSCSI show CMD output
  #   debug:
  #     var: na_output
  #   tags:
  #     - netapp

  - name: store SVM iSCSI target IQN in register
    set_fact:
      na_tiqn: "{{ na_output.msg.stdout_lines_filter[0] | regex_search('iqn.*') }}"
    tags:
      - netapp
  
  - name: get igroup info from cluster
    netapp.ontap.na_ontap_rest_info: 
      <<: *netapp_login
      # use_rest: always
      gather_subset:
        - protocols/san/igroups
        # - igroup_info
    register: ontap_info
    tags:
      - netapp

  # - name: display ontap igroup info for event svm
  #   debug:
  #     var: item.uuid
  #   loop: "{{ ontap_info.ontap_info['protocols/san/igroups'].records }}"
  #   when:
  #     - item.svm.name == "svm_jmnautoevent01_auto"
  #   tags:
  #     - netapp

  - name: build igroup uuid list
    set_fact: 
      naigroup_uuid: "{{ naigroup_uuid | default([]) + [item.uuid] | unique }}"
    loop: "{{ ontap_info.ontap_info['protocols/san/igroups'].records }}"
    when:
      - item.svm.name == "svm_{{ chkd_eventname }}_auto"
    tags:
      - netapp

  - name: get svm igroup info
    ansible.builtin.uri:
      url_username: "{{ login.username }}"
      url_password: "{{ login.password }}"
      url: https://{{ login.hostname }}/api/protocols/san/igroups/{{ item }}/initiators/
      validate_certs: false
      return_content: true
      force_basic_auth: true
    register: this
    loop: "{{ naigroup_uuid }}"
    tags:
      - netapp

  - name: set source iqn fact for blades in igroup
    set_fact:
      na_siqn: "{{ na_siqn | default([]) + [item.json.records[0].name] | unique | sort }}"
    loop: "{{ this.results }}"
    tags:
      - netapp

  - name: Print target IQN target from SVM
    debug:
      msg: 
        - " The target iqn on event {{ eventname }} svm is: {{ na_tiqn }}"
        - " the source iqn's are: {{ na_siqn }}"
    tags:
      - netapp

# - name: GET CMC Inventory - MX7K
#   hosts: mx7k_cmc
#   connection: local
#   gather_facts: false

#   vars:
#     cmc_baseuri: "{{ baseuri }}"
#     dell_login: &dell_login
#       username: "{{ username }}"
#       password: "{{ password }}"
#     template: ~/jmnauto/dell/

#   tasks:
#   - name: Gather info from MX7K
#     dellemc.openmanage.ome_device_info:
#       # fact_subset: detailed_inventory
#       hostname: "{{ baseuri }}"
#       username: "{{ username }}"
#       password: "{{ password }}"
#       # <<: *dell_login
#       validate_certs: false
#     register: CMCDevInfo
#     tags:
#       - cmc

  # - name: print native OME device info
  #   debug:
  #     var: CMCDevInfo.device_info.["@odata.count"]
  #   tags:
  #     - cmc
  
  # - name: Copy results to output file
  #   ansible.builtin.copy:
  #     content: "{{ CMCDevInfo | to_nice_json }}"
  #     dest: "{{ template }}_CMCDevInfo-{{ inventory_hostname }}.json"
  #   delegate_to: localhost
  #   tags:
  #     - cmc

  # - name: Print results of register #working query of CMC device info
  #   debug:
  #     var: CMCDevInfo.ansible_facts.device_info
  #   tags:
  #     - cmc
  
  # - name: Print results of register
  #   debug:
  #     var: item.Id
  #   loop: "{{ CMCDevInfo.device_info.value }}"
  #   loop_control:
  #     label: "{{ item.Id }}"
  #   delegate_to: localhost
  #   when:
  #     - item.Model == 'PowerEdge MX760c' or item.Model == 'PowerEdge MX740c'
  #   tags:
  #     - cmc

- name: Dell iDRAC Event Configuration
  hosts: event_blades
  connection: local
  gather_facts: false

  vars:
    hosts_count: 
      - 1
      - 2
    year: "2024"
    month: "05"
    # eventvlan: 3015
    blade_login: &blade_login
      username: "{{ username }}"
      password: "{{ password }}"
    idrac_login: &idrac_login
      idrac_user: "{{ username }}"
      idrac_password: "{{ password }}"
    template: ~/jmnauto/dell/
    reboot_uri: "/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"
    retries_count: 10
    polling_interval: 3
    common_iscsi_attributes:
      IscsiDev1Con1DhcpEnDis: "Disabled"
      IscsiDev1Con1EnDis: "Enabled"
      IscsiDev1Con1Gateway: "192.168.5.254"
      IscsiDev1Con1Interface: "NIC.Mezzanine.1A-1-1"
      IscsiDev1Con1Lun: "0"
      IscsiDev1Con1Port: 3260
      IscsiDev1Con1Protocol: "IPv4"
      IscsiDev1Con1Retry: 3
      IscsiDev1Con1RevChapName: ""
      IscsiDev1Con1RevChapSecret: ""
      IscsiDev1Con1TargetIp: "192.168.5.254"
      IscsiDev1Con1TargetName: "{{ hostvars['localhost']['na_tiqn'] }}"
      IscsiDev1Con1TgtDhcpEnDis: "Disabled"
      IscsiDev1Con1Timeout: 10000
      IscsiDev1Con1VlanEnDis: "Enabled"
      IscsiDev1Con1VlanId: "{{ eventvlan|int }}"
      IscsiDev1Con1VlanPriority: 0
      IscsiDev1Con2DhcpEnDis: "Disabled"
      IscsiDev1Con2EnDis: "Enabled"
      IscsiDev1Con2Gateway: "192.168.5.254"
      IscsiDev1Con2Interface: "NIC.Mezzanine.1A-1-1"
      IscsiDev1Con2Lun: "0"
      IscsiDev1Con2Port: 3260
      IscsiDev1Con2Protocol: "IPv4"
      IscsiDev1Con2Retry: 3
      IscsiDev1Con2RevChapName: ""
      IscsiDev1Con2RevChapSecret: ""
      IscsiDev1Con2TargetIp: "192.168.5.254"
      IscsiDev1Con2TargetName: "{{ hostvars['localhost']['na_tiqn'] }}"
      IscsiDev1Con2TgtDhcpEnDis: "Disabled"
      IscsiDev1Con2Timeout: 10000
      IscsiDev1Con2VlanEnDis: "Enabled"
      IscsiDev1Con2VlanId: "{{ eventvlan|int }}"
      IscsiDev1Con2VlanPriority: 0
      IscsiDev1EnDis: "Enabled"
      IscsiDev1Con1Ip: "192.168.5.{{ 10 + blade_id|int }}"
      IscsiDev1Con1Mask: "255.255.255.0"
      IscsiDev1Con2Ip: "192.168.5.{{ 20 + blade_id|int }}"
      IscsiDev1Con2Mask: "255.255.255.0"
      IscsiInitiatorName: "iqn.{{ year }}-{{ month }}.jmn.ncrc:host{{ blade_index_id|int }}"
    common_iscsi_attributes760:
      IscsiDev1Con1DhcpEnDis: "Disabled"
      IscsiDev1Con1EnDis: "Enabled"
      IscsiDev1Con1Gateway: "192.168.5.254"
      IscsiDev1Con1Interface: "NIC.Mezzanine.1A-1-1"
      IscsiDev1Con1Lun: "0"
      IscsiDev1Con1Port: 3260
      IscsiDev1Con1Protocol: "IPv4"
      IscsiDev1Con1Retry: 3
      IscsiDev1Con1RevChapName: ""
      IscsiDev1Con1RevChapSecret: ""
      IscsiDev1Con1TargetIp: "192.168.5.254"
      IscsiDev1Con1TargetName: "{{ hostvars['localhost']['na_tiqn'] }}"
      IscsiDev1Con1TgtDhcpEnDis: "Disabled"
      IscsiDev1Con1Timeout: 10000
      IscsiDev1Con1VlanEnDis: "Enabled"
      IscsiDev1Con1VlanId: "{{ eventvlan|int }}"
      IscsiDev1Con1VlanPriority: 0
      IscsiDev1Con2DhcpEnDis: "Disabled"
      IscsiDev1Con2EnDis: "Enabled"
      IscsiDev1Con2Gateway: "192.168.5.254"
      IscsiDev1Con2Interface: "NIC.Mezzanine.1A-1-1"
      IscsiDev1Con2Lun: "0"
      IscsiDev1Con2Port: 3260
      IscsiDev1Con2Protocol: "IPv4"
      IscsiDev1Con2Retry: 3
      IscsiDev1Con2RevChapName: ""
      IscsiDev1Con2RevChapSecret: ""
      IscsiDev1Con2TargetIp: "192.168.5.254"
      IscsiDev1Con2TargetName: "{{ hostvars['localhost']['na_tiqn'] }}"
      IscsiDev1Con2TgtDhcpEnDis: "Disabled"
      IscsiDev1Con2Timeout: 10000
      IscsiDev1Con2VlanEnDis: "Enabled"
      IscsiDev1Con2VlanId: "{{ eventvlan|int }}"
      IscsiDev1Con2VlanPriority: 0
      IscsiDev1EnDis: "Enabled"
      IscsiDev1Con1Ip: "192.168.5.{{ 10 + blade_id|int }}"
      IscsiDev1Con1Mask: "255.255.255.0"
      IscsiDev1Con2Ip: "192.168.5.{{ 20 + blade_id|int }}"
      IscsiDev1Con2Mask: "255.255.255.0"
      IscsiInitiatorName: "iqn.{{ year }}-{{ month }}.jmn.ncrc:host{{ blade_index_id|int }}"
    ansible_python_interpreter: "/usr/bin/env python3"
    idrac_osd_command_allowable_values: ["BootToNetworkISO", "GetAttachStatus", "DetachISOImage"]
    idrac_osd_command_default: "GetAttachStatus"
    GetAttachStatus_Code:
      DriversAttachStatus:
        "0": "NotAttached"
        "1": "Attached"
      ISOAttachStatus:
        "0": "NotAttached"
        "1": "Attached"
    idrac_https_port: 443
    expose_duration: 1080
    command: "{{ idrac_osd_command_default }}"
    validate_certs: no
    force_basic_auth: yes
    share_name: "10.200.4.229:/vol_gold_lun_nfs"
    ubuntu_iso: esxi_8.0.0u1a-21813344_x86-64-customized.iso

  tasks:
  # - name: VERIFY sanitized state blade IP ADDR

  # - name: VERIFY sanitized state BIOS iSCSI

  - name: Gather date from localhost
    ansible.builtin.command: date '+%b-%d-%Y-%H-%M-%S'
    register: local_date
    run_once: true
    delegate_to: localhost
    changed_when: false
    tags:
      - config_bios

  - name: get blade count 
    set_fact:
      blade_count: "{{ ansible_play_hosts_all | count }}"
    delegate_to: localhost
    tags:
      - config_bios

  - name: print blade count
    debug:
      var: blade_count
    delegate_to: localhost
    tags:
      - config_bios

  - name: get iqn count
    set_fact:
      iqn_count: "{{ hostvars['localhost']['na_siqn'] | count }}"
    delegate_to: localhost
    tags:
      - config_bios

  - name: fail if event blades count > iqn count
    ansible.builtin.fail:
      msg: The blade count is greater than the iqn count, check these values and re-run the script
    when: blade_count|int > iqn_count|int
    delegate_to: localhost
    tags:
      - config_bios

  - name: GET blade BIOS settings
    community.general.redfish_info:
      category: Systems
      command: GetBiosAttributes
      baseuri: "{{ baseuri }}"
      # username: "{{ username }}"
      # password: "{{ password }}"
      <<: *blade_login
    register: BiosAttributes
    tags:
      - config_bios

  # - name: print blade BIOS settings
  #   debug:
  #     var: BiosAttributes
  #   delegate_to: localhost
  #   tags:
  #     - blades

  # - name: GET blade NIC Inventory
  #   community.general.redfish_info:
  #     category: Systems
  #     command: GetNicInventory
  #     baseuri: "{{ baseuri }}"
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *blade_login
  #   register: NicInv
  #   tags:
  #     - blades

  # - name: Copy results to output file
  #   ansible.builtin.copy:
  #     content: "{{ BiosAttributes | to_nice_json }}"
  #     dest: "{{ template }}_blade-{{ inventory_hostname }}_BiosAttributes_{{ local_date.stdout }}.json"
  #   tags:
  #     - blades
  #     # - debug

  # - name: Copy NIC Inventory results to output file
  #   ansible.builtin.copy:
  #     content: "{{ NicInv | to_nice_json }}"
  #     dest: "{{ template }}_blade-{{ inventory_hostname }}_NicInv_{{ local_date.stdout }}.json"
  #   tags:
  #     - blades
  #     # - debug
  
  # - name: Print Blade Info
  #   debug:
  #     var: BiosAttributes | json_query('redfish_facts.bios_attribute.entries[0][*].SystemServiceTag')
  #   tags:
  #     - debug

  - name: Set Blade Unique ID
    set_fact:
      blade_index_id: "{{ ansible_play_hosts_all.index(inventory_hostname) + 1 }}"
    tags:
      - config_bios

  - name: print blade unique ID
    debug:
      var: blade_index_id
    tags:
      - config_bios

  - name: print na_siqn register
    debug:
      var: hostvars['localhost']['na_siqn']
    delegate_to: localhost
    tags:
      - config_bios

  - name: print unique iSCSI Initiator Name
    debug:
      msg: iqn.{{ year }}-{{ month }}.jmn.ncrc:host{{ blade_index_id }}
    delegate_to: localhost
    tags:
      - config_bios

  # - name: CONFIGURE unique iSCSI attributes on blade BIOS
  #   community.general.redfish_config:
  #     category: Systems
  #     command: SetBiosAttributes
  #     bios_attributes: 
  #       IscsiDev1Con1Ip: "192.168.5.{{ 10 + blade_index_id|int }}"
  #       IscsiDev1Con1Mask: "255.255.255.0"
  #       IscsiDev1Con2Ip: "192.168.5.{{ 20 + blade_index_id|int }}"
  #       IscsiDev1Con2Mask: "255.255.255.0"
  #       IscsiInitiatorName: "iqn.{{ year }}-{{ month }}.jmn.ncrc:host-{{ blade_index_id|int }}"
  #     baseuri: "{{ baseuri }}"
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *blade_login
  #   # loop: "{{ hosts_count }}"
  #   register: unique_bios_iscsi_attributes
  #   tags:
  #     - blades

  - name: CONFIGURE unique iSCSI attributes on blade BIOS OME MX740c's
    dellemc.openmanage.idrac_bios:
      idrac_ip: "{{ baseuri }}"
      <<: *idrac_login
      validate_certs: false
      attributes: "{{ common_iscsi_attributes }}"
    register: unique_bios_iscsi_attributes740
    when: model == 'PowerEdge MX740c'
    tags:
      - config_bios

  - name: print unique_bios iscsi attributes register
    debug:
      var: unique_bios_iscsi_attributes740
    when: model == 'PowerEdge MX740c'
    tags:
      - config_bios

  - name: CONFIGURE unique iSCSI attributes on blade BIOS OME MX760c's
    dellemc.openmanage.idrac_bios:
      idrac_ip: "{{ baseuri }}"
      <<: *idrac_login
      validate_certs: false
      attributes: "{{ common_iscsi_attributes760 }}"
    register: unique_bios_iscsi_attributes760
    when: model == 'PowerEdge MX760c'
    tags:
      - config_bios

  - name: print unique_bios iscsi attributes register
    debug:
      var: unique_bios_iscsi_attributes760
    when: model == 'PowerEdge MX760c'
    tags:
      - config_bios

  # - name: CONFIGURE iSCSI IQN on blade BIOS OME
  #   dellemc.openmanage.idrac_bios:
  #     idrac_ip: "{{ baseuri }}"
  #     <<: *idrac_login
  #     validate_certs: false
  #     attributes: 
  #       IscsiInitiatorName: "iqn.{{ year }}-{{ month }}.jmn.ncrc:host-{{ blade_index_id|int }}"
  #   register: event_iqn_name
  #   tags:
  #     - iqn

  # - name: print iscsi iqn result
  #   debug:
  #     var: event_iqn_name
  #   tags:
  #     - iqn

  # - name: CONFIGURE common iSCSI attributes on blade BIOS
  #   community.general.redfish_config:
  #     category: Systems
  #     command: SetBiosAttributes
  #     bios_attributes: "{{ common_iscsi_attributes }}"
  #     baseuri: "{{ baseuri }}"
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *blade_login
  #   register: common_bios_iscsi_attributes
  #   tags:
  #     - blades

  # - name: CONFIGURE common iSCSI attributes on blade BIOS OME
  #   dellemc.openmanage.idrac_bios:
  #     attributes: "{{ common_iscsi_attributes }}"
  #     idrac_ip: "{{ baseuri }}"
  #     validate_certs: false
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *idrac_login
  #   register: common_bios_iscsi_attributes
  #   tags:
  #     - blades

  # - name: print common_bios iscsi attributes register
  #   debug:
  #     var: common_bios_iscsi_attributes
  #   tags:
  #     - blades

  # - name: CONFIGURE iSCSI target iqn on blade BIOS
  #   community.general.redfish_config:
  #     category: Systems
  #     command: SetBiosAttributes
  #     bios_attributes: 
  #       IscsiInitiatorName: "iqn.{{ year }}-{{ month }}.jmn.ncrc:host-{{ blade_index_id|int }}"
  #     baseuri: "{{ baseuri }}"
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *blade_login
  #   register: iscsi_tiqn
  #   tags:
  #     - blades

  # DELL ONLY: Updating BIOS settings requires creating a configuration job
  # to schedule the BIOS update, so comment out below for non-Dell systems.

  # - name: Create BIOS configuration job (schedule BIOS setting update)
  #   community.general.idrac_redfish_command:
  #     category: Systems
  #     command: CreateBiosConfigJob
  #     baseuri: "{{ baseuri }}"
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *blade_login
  #   # when: common_bios_iscsi_attributes.changed or unique_bios_iscsi_attributes.changed
  #   tags:
  #     - blades

  # - name: Reboot system to apply new BIOS settings
  #   community.general.redfish_command:
  #     category: Systems
  #     command: PowerReboot
  #     baseuri: "{{ baseuri }}"
  #     # username: "{{ username }}"
  #     # password: "{{ password }}"
  #     <<: *blade_login
  #   register: reboot_result
  #   # changed_when: reboot_result.changed == 'true'
  #   # when: common_bios_iscsi_attributes.changed or unique_bios_iscsi_attributes.changed
  #   tags:
  #     - blades

  # - name: debug reboot_result
  #   debug:
  #     var: reboot_result
  #   tags:
  #     - blades

  # - name: Wait 10 mins for blade to reboot
  #   wait_for:
  #     timeout: 600
  #   delegate_to: localhost
    # when: reboot_result.msg == 'Action was successful' and reboot_result.changed == 'true'

  # - name: Poll event servers after reboot
  #   uri:
  #     url: "https://{{ cmc_IP }}/api/DeviceService/Devices({{ blade_uniqueID }})/SystemUpTime"
  #     user: "{{ username }}"
  #     password: "{{ password }}"
  #     method: "GET"
  #     use_proxy: no
  #     status_code: 200, 202
  #     return_content: yes
  #     validate_certs: no
  #     force_basic_auth: yes
  #     headers:
  #       Content-Type: "application/json"
  #       Accept: "application/json"
  #   register: reboot_result
  #   until: reboot_result.json.systemUpTime|int > 200
  #   retries: "{{ retries_count }}"
  #   delay: "{{ polling_interval }}"
  #   tags:
  #     - blades
  #     - debug

  # - name: Poll event servers after reboot
  #   uri:
  #     url: "https://{{ baseuri }}/redfish/v1/Systems/System.Embedded.1/"
  #     user: "{{ username }}"
  #     password: "{{ password }}"
  #     method: "GET"
  #     use_proxy: no
  #     status_code: 200, 202
  #     return_content: yes
  #     validate_certs: no
  #     force_basic_auth: yes
  #     headers:
  #       Content-Type: "application/json"
  #       Accept: "application/json"
  #   register: reboot_result
  #   until: reboot_result.status == 200
  #   retries: "{{ retries_count }}"
  #   delay: "{{ polling_interval }}"
  #   tags:
  #     - blades
  #     - get_bios
    
  - name: GET blade event BIOS settings
    community.general.redfish_info:
      category: Systems
      command: GetBiosAttributes
      baseuri: "{{ baseuri }}"
      # username: "{{ username }}"
      # password: "{{ password }}"
      <<: *blade_login
    register: EventBiosAttributes
    tags:
      - config_bios
      - get_bios
      - os_deploy

  - name: print blade event BIOS settings
    debug:
      var: EventBiosAttributes
    delegate_to: localhost
    tags:
      - config_bios
      - get_bios
      - os_deploy
      
  - name: print eventname
    debug:
      var: hostvars['localhost']['chkd_eventname']
    delegate_to: localhost
    tags:
      - os_deploy

  - name: INSTALL OS - find the URL for the DellOSDeploymentService
    ansible.builtin.uri:
      url: "https://{{ baseuri }}/redfish/v1/Systems/System.Embedded.1"
      user: "{{ idrac_login.idrac_user }}"
      password: "{{ idrac_login.idrac_password }}"
      method: GET
      headers:
        Accept: "application/json"
        OData-Version: "4.0"
      status_code: 200
      validate_certs: "{{ validate_certs }}"
      force_basic_auth: "{{ force_basic_auth }}"
    register: result
    delegate_to: localhost
    tags:
      - os_deploy
      - getisostatus

  - name: INSTALL OS - debug result return
    debug:
      var: result
    tags:
      - os_deploy
      - getisostatus

  - name: INSTALL OS - find the URL for the DellOSDeploymentService
    ansible.builtin.set_fact:
      idrac_osd_service_url: "{{ result.json.Links.Oem.Dell.DellOSDeploymentService['@odata.id'] }}"
    when:
      - result.json.Links.Oem.Dell.DellOSDeploymentService is defined
  - block:
      - name: INSTALL OS - get ISO attach status
        ansible.builtin.uri:
          url: "https://{{ baseuri }}{{ idrac_osd_service_url }}/Actions/DellOSDeploymentService.GetAttachStatus"
          user: "{{ idrac_login.idrac_user }}"
          password: "{{ idrac_login.idrac_password }}"
          method: POST
          headers:
            Accept: "application/json"
            Content-Type: "application/json"
            OData-Version: "4.0"
          body: "{}"
          status_code: 200
          validate_certs: "{{ validate_certs }}"
          force_basic_auth: "{{ force_basic_auth }}"
        register: attach_status
        delegate_to: localhost
      - name: set ISO attach status as a fact variable
        ansible.builtin.set_fact:
          idrac_iso_attach_status: "{{ idrac_iso_attach_status | default({}) | combine({item.key: item.value}) }}"
        with_dict:
          DriversAttachStatus: "{{ attach_status.json.DriversAttachStatus }}"
          ISOAttachStatus: "{{ attach_status.json.ISOAttachStatus }}"
    when:
      - idrac_osd_service_url is defined
      - idrac_osd_service_url|length > 0
  - block:
      - name: INSTALL OS - detach ISO image if attached
        ansible.builtin.uri:
          url: "https://{{ baseuri }}{{ idrac_osd_service_url }}/Actions/DellOSDeploymentService.DetachISOImage"
          user: "{{ idrac_login.idrac_user }}"
          password: "{{ idrac_login.idrac_password }}"
          method: POST
          headers:
            Accept: "application/json"
            Content-Type: "application/json"
            OData-Version: "4.0"
          body: "{}"
          status_code: 200
          validate_certs: "{{ validate_certs }}"
          force_basic_auth: "{{ force_basic_auth }}"
        register: detach_status
        delegate_to: localhost
      - ansible.builtin.debug:
          msg: "Successfuly detached the ISO image"
    when:
      - idrac_osd_service_url is defined and idrac_osd_service_url|length > 0
      - idrac_iso_attach_status
      - idrac_iso_attach_status.ISOAttachStatus == "Attached" or
        idrac_iso_attach_status.DriversAttachStatus == "Attached"
    tags:
      - os_deploy
      - getisostatus
  - block:
      - name: debug ISO STATUS
        debug:
          var: attach_status
        tags:
          - getisostatus

  - name: INSTALL OS - boot to network ISO
    dellemc.openmanage.idrac_os_deployment:
      idrac_ip: "{{ baseuri }}"
      idrac_user: "{{ idrac_login.idrac_user }}"
      idrac_password: "{{ idrac_login.idrac_password }}"
      share_name: "{{ share_name }}"
      iso_image: "{{ ubuntu_iso }}"
      expose_duration: "{{ expose_duration }}"
      validate_certs: False
    register: boot_to_network_iso_status
    delegate_to: localhost
    tags:
      - os_deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Issue requires triage. type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant