Ansible Examples
Example for connecting to Orchestrator API
Your use of this Software is pursuant to the Silver Peak Disclaimer - see the README file for this repository
Basic LOGIN function without multi-factor authentication, requires Orchestrator URL, User, Password
Throughout example LOGIN response is stored and used in variable {{ orch }}
NOTE: orch_ip can be IP address or URL, if the orch_user is using RBAC, they must have R/O or R/W access
- name: Orchestrator Login
uri:
validate_certs: # (yes/no)
url: "https://{{ orch_ip }}/gms/rest/authentication/login"
body: {"user": "{{ orch_user }}", "password": "{{ orch_password }}"}
body_format: json
return_content: yes
method: POST
headers:
Content-Type: "application/json"
register: orch
LOGOUT function, requires Orchestrator URL, and {{ orch }}
- name: Orchestrator Logout
uri:
validate_certs: # (yes/no)
url: "https://{{ orchip }}/gms/rest/authentication/logout"
body_format: json
return_content: yes
method: GET
headers:
Content-Type: "application/json"
Cookie: "{{ orch.set_cookie }}"
X-XSRF-TOKEN: "{{ orch.cookies.orchCsrfToken }}"
Sample GET function, requires Orchestrator URL, GET URL (shown as variable), and {{ orch }}
GET response stored in variable {{ getReturn }}
- name: Get Sample
uri:
validate_certs: # (yes/no)
url: "https://{{ orchip }}/gms/rest/{{ get_url }}"
body_format: json
return_content: yes
method: GET
headers:
Content-Type: "application/json"
Cookie: "{{ orch.set_cookie }}"
X-XSRF-TOKEN: "{{ orch.cookies.orchCsrfToken }}"
register: getReturn
Sample POST function, requires Orchestrator URL, POST URL (shown as variable), and {{ orch }}
NOTE: for error handling, POST STATUS may be returned as 200 or 204, either hardcode or leverage variable accordingly
- name: Post Sample
uri:
validate_certs: # (yes/no)
url: "https://{{ orchip }}/gms/rest/{{ post_url }}"
body: "{{ contents }}"
body_format: json
return_content: yes
status_code: "{{ post_status }}"
method: POST
headers:
Content-Type: "application/json"
Cookie: "{{ orch.set_cookie }}"
X-XSRF-TOKEN: "{{ orch.cookies.orchCsrfToken }}"
Sample PUT function, requires Orchestrator URL, PUT URL (shown as variable), and {{ orch }}
NOTE: for error handling, 204 status code may be returned on successful PUT and should be set accordingly as necessary
- name: Put Sample
uri:
validate_certs: # (yes/no)
url: "https://{{ orchip }}/gms/rest/{{ put_url }}"
body: "{{ contents }}"
body_format: json
return_content: yes
status_code: 204
method: PUT
headers:
Content-Type: "application/json"
Cookie: "{{ orch.set_cookie }}"
X-XSRF-TOKEN: "{{ orch.cookies.orchCsrfToken }}"
Updated 4 months ago