Solved

Executing QCommand qoperation execscript from Ansible API URI module

  • 11 May 2023
  • 2 replies
  • 138 views

Badge +2

Can anyone help me with the Ansible uri module syntax to run a qscript? Specifically I’d like to be able to execute the AuxCopyReport
https://documentation.commvault.com/2023/expert/AuxCopyReport.html

 

- name: "Run aux copy report"
uri:
url: "https://{{ cv_server }}/webconsole/api/QCommand/qoperation%20execute"
method: POST
body_format: json
body:
"what goes here?"
force_basic_auth: yes
headers:
AuthToken: "{{ auth_token }}"
Content-Type: "application/json"
Accept: "application/json "
validate_certs: no
register: cv_auxcopy

 

icon

Best answer by M0nda 15 May 2023, 15:54

View original

2 replies

Userlevel 2
Badge +8

You are using the wrong api.

You are using qoperation execute

You need qoperation execscript.

nothing goes in the body everything is submitted in the uri.

Badge +2

Thanks for the guidance @clecky here’s the final answer for anyone who comes past this in the future

  - name: "Run aux copy report"
uri:
url: "https://{{ cv_server }}/webconsole/api/QCommand/qoperation%20execscript{{ qcmd | urlencode }}"
method: POST
headers:
AuthToken: "{{ auth_token }}"
Accept: "application/json "
register: cv_auxcopy
vars:
qcmd: " -sn QS_AuxCopyReport"

On a side note if you get the following @errorCode: 2 response check the credentials have the necessary permissions to execute the script
 

"json": {
"CVGui_GenericResp": {
"@errorCode": "2",
"@errorMessage": "Operation failed"
}
},

 

Reply