Skip to main content
Solved

Executing QCommand qoperation execscript from Ansible API URI module

  • May 11, 2023
  • 2 replies
  • 228 views

Forum|alt.badge.img+1

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

 

Best answer by M0nda

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"
}
},

 

2 replies

clecky
Vaulter
Forum|alt.badge.img+10
  • Vaulter
  • May 12, 2023

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.


Forum|alt.badge.img+1
  • Author
  • Novice
  • Answer
  • May 15, 2023

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"
}
},