Hi,
I believe I am getting the syntax wrong for passing in a variable to an API, raw json body but googling on and off for days has not helped. Hopefully someone can point me in the right direction on here. The playbook is trying to add a new Dell server iDRAC into open manage enterprise (OME) via a Discovery job. The variable I am trying to pass into the json body is {{ dell_idrac_root_password }}. I have already tried wrapping the variable in quotation marks, single marks, no brackets at all etc etc, everyway I can think to present the variable.
Calling the playbook with extra-vars (this includes the password variable):
ansible-playbook R450_ome_deploy_server_from_template_test5.yml --extra-vars "dell_ome_server=delomelab.madeup.com dell_ome_user=username dell_ome_password='fakePassword' dell_ome_device_idrac_ip=10.20.254.10 dell_idrac_root_password='fakePassword'" -v
playbook code:
- name: Add server into OME
hosts: localhost
connection: local
gather_facts: 'no'
tasks:
- set_fact:
random: "{{ 9999999999999999 | random }}"
run_once: yes
- name: Add device into OME for fresh discovery
uri:
url: >-
https://{{ dell_ome_server
}}/api/DiscoveryConfigService/DiscoveryConfigGroups
user: '{{ dell_ome_user }}@email.com'
password: '{{ dell_ome_password }}'
method: POST
body_format: json
body:
DiscoveryConfigGroupName: Discovery-{{ random }}
DiscoveryConfigGroupDescription: 'null'
DiscoveryStatusEmailRecipient: email@email.com
DiscoveryConfigModels:
- DiscoveryConfigId: 331105536
DiscoveryConfigDescription: ''
DiscoveryConfigStatus: ''
DiscoveryConfigTargets:
- DiscoveryConfigTargetId: 0
NetworkAddressDetail: "{{ dell_ome_device_idrac_ip }}"
AddressType: 30
Disabled: false
Exclude: false
ConnectionProfileId: 0
ConnectionProfile: >-
{"profileName":"","profileDescription":"","type":"DISCOVERY","credentials":[{"id":0,"type":"WSMAN","authType":"Basic","modified":false,"credentials":{"username":"root","password":{{ dell_idrac_root_password }},"caCheck":false,"cnCheck":false,"port":443,"retries":3,"timeout":60,"isHttp":false,"keepAlive":false}}]}
DeviceType:
- 1000
Schedule:
RunNow: true
RunLater: false
Cron: startnow
StartTime: ''
EndTime: ''
CreateGroup: true
TrapDestination: false
use_proxy: 'no'
status_code: 201
return_content: 'yes'
validate_certs: 'no'
force_basic_auth: 'yes'
headers:
Content-Type: application/json
Accept: application/json
register: ome_template_device_add_response
This is the error output I am receiving:
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match âallâ
PLAY [Add server into OME] ************************************************************************************************************************************************************************************************************
TASK [set_fact] ***********************************************************************************************************************************************************************************************************************
ok: [localhost] => {âansible_factsâ: {ârandomâ: â437289450216118â}, âchangedâ: false}
TASK [Add device into OME for fresh discovery] ****************************************************************************************************************************************************************************************
[WARNING]: Module did not set no_log for password
fatal: [localhost]: FAILED! => {âaccess_control_allow_originâ: â*â, âchangedâ: false, âconnectionâ: âcloseâ, âcontentâ: â{"error":{"code":"Base.1.0.GeneralError","message":"A general error has occurred. See ExtendedInfo for more information.","@Message.ExtendedInfo":[{"MessageId":"CGEN1008","RelatedProperties":,"Message":"Unable to process the request because an error occurred.","MessageArgs":,"Severity":"Critical","Resolution":"Retry the operation. If the issue persists, contact your system administrator."}]}}â, âcontent_lengthâ: â399â, âcontent_security_policyâ: âdefault-src âselfâ âunsafe-evalâ; connect-src *; style-src âselfâ âunsafe-inlineâ blob:; script-src âselfâ âunsafe-inlineâ âunsafe-evalâ; img-src âselfâ blob: data:â, âcontent_typeâ: âapplication/json;charset=UTF-8â, âdateâ: âTue, 30 Apr 2024 10:23:17 GMTâ, âelapsedâ: 21, âjsonâ: {âerrorâ: {â@Message.ExtendedInfoâ: [{âMessageâ: âUnable to process the request because an error occurred.â, âMessageArgsâ: , âMessageIdâ: âCGEN1008â, âRelatedPropertiesâ: , âResolutionâ: âRetry the operation. If the issue persists, contact your system administrator.â, âSeverityâ: âCriticalâ}], âcodeâ: âBase.1.0.GeneralErrorâ, âmessageâ: âA general error has occurred. See ExtendedInfo for more information.â}}, âmsgâ: âStatus code was 400 and not [201]: HTTP Error 400: 400â, âodata_versionâ: â4.0â, âredirectedâ: false, âserverâ: âApacheâ, âset_cookieâ: ârememberMe=deleteMe; Path=/api; Max-Age=0; Expires=Mon, 29-Apr-2024 10:23:38 GMT; SameSite=laxâ, âstatusâ: 400, âstrict_transport_securityâ: âmax-age=31536000; includeSubDomainsâ, âurlâ: âSherwin-Williams Paints, Stains, Supplies and Coating Solutionsâ, âx_content_type_optionsâ: ânosniffâ, âx_frame_optionsâ: âSAMEORIGINâ, âx_xss_protectionâ: â1; mode=blockâ}
Any help appreciated, thanks in advance :).