Have problems with PB make API calls

20 views
Skip to first unread message

William “Will” Flow

unread,
Jul 8, 2024, 2:57:43 PMJul 8
to Ansible Project

I have a new project I am working on and could use some help. The project is from upper management they want me to write a Playbook that can turn outlets on and off using  an APC APDU10450SM with the API

 

I looked and could not find a collection to use, but I can send API calls to the unit, but unlike what I am used too, that being using a token, you have to send the username and password then the unit will send back a token and that is what is used for executing commands.

 

I can mock this up in Postman and it works fine, however I have issues when I do this in my Playbook I am in the weeds here would appreciate any help

Cheers

Bill

Brian Coca

unread,
Jul 8, 2024, 3:46:37 PMJul 8
to ansible...@googlegroups.com
I used to have some playbooks that did the same, with the first task
calling the API and retrieving the token into a registered var, while
subsequent tasks using that var as input for
authentication/authorization:

- get_url: ...
register: auth_token

- access_api:
token: auth_token.body/header/etc

--
----------
Brian Coca (he/him/yo)

Reply all
Reply to author
Forward
0 new messages