I am trying to automate the cloud director deployment and post configuration using ansible. Using URI module to pass the nfs storage, db and account details but it failed with "msg: 'Status code was 400 and not [200]: HTTP Error 400: BAD REQUEST'". Here is the code snippet I am using to
- name: configure cloud director post deployment
uri:
url: 'https://{{ vcd_ip }}:5480/api/1.0.0/systemSetup'
method: POST
body: '{"applianceType":"primary","storage":{ "nfs":"nfs_ip:/share"},"appliance":{"dbPassword":{{ passwd }},"ceip":"checked"},"installation":{"name":"VCD10.3","id":"1"},"sysAdmin":{"username":"administrator","password":{{ passwd }},"fullName":"xxxx","email":"[email protected]"}}'
headers:
Accept: 'application/*;version=35.2'
Content-Type: application/json
Authorization: 'Basic xcfgrtyunvdryrtpiy='
validate_certs: false
register: result
Below is the output
json:
error: '400 Bad Request: Failed to decode JSON object: Expecting value: line 1 column 99 (char 98)'
msg: 'Status code was 400 and not [200]: HTTP Error 400: BAD REQUEST'
redirected: false
server: nginx
status: 400
Have also tried with Bearer authorization with the session token I have collected using this URL https://vcd_ip:5480/api/1.0.0/sessions
Fix the JSON format and expand the substitutions. Put it into the vars and use Folded Style. It's easier to read. For example,
Note: You can use the YAML format as well
gives
In your case, you might want to try