I am trying to get token from salt-api with following state:
Request token from API:
http.query:
- name:
https://salt-master:8080/login - match: token
- method: POST
- header_list: '["Accept: application/json"]'
- verify_ssl: False
- data: 'username=myuser&password=changeme&eauth=pam'
- text: True
this is output of above state:
server:
----------
ID: Request token from API
Function: http.query
Name:
https://salt-master:8080/login Result: True
Comment: Match text "token" was found.
body: {"return": [{"perms": ["@wheel", "@runner"], "start": 1490833459.1142299, "token": "dfd2cf3d2fef128274c43bdc08380c0a3f2bccd6", "expire": 1490876659.1142311, "user": "myuser", "eauth": "pam"}]}
status: 200
text: {"return": [{"perms": ["@wheel", "@runner"], "start": 1490833459.1142299, "token": "dfd2cf3d2fef128274c43bdc08380c0a3f2bccd6", "expire": 1490876659.1142311, "user": "myuser", "eauth": "pam"}]}
Started: 20:24:18.026066
Duration: 42.561 ms
Changes:
Summary for server
------------
Succeeded: 1
Failed: 0
am I able to get text as dictionary from above state run? I tried with following state, but it failed:
echo token:
cmd.run:
- name: echo {{text.return[0].token}}
Data failed to compile:
----------
Rendering SLS 'base:xxxxx.test1' failed: Jinja variable 'text' is undefined
ERROR: Minions returned with non-zero exit code