Generating a registration token for Ansible automation


I’m trying to generate a registration token and have been following some posts by Vincent that are a couple of years old now, with no success.

So just wanted to validate the correct process, urls to use etc.

This is what I have currently, in Ansible:

  • name: Get the default project id
    action: uri
    url=“http://<host_redacted>:8080/v1/projects” return_content=yes
    register: project_id

  • name: Return the registration token URL of Rancher server
    action: uri
    url=“http://<host_redacted>:8080/v1/registrationtokens?projectId={{ project_id.json[‘data’][0][‘id’] }}” return_content=yes
    register: rancher_token_url

  • name: Return the registration URL of Rancher server
    action: uri
    url={{ rancher_token_url.json[‘links’][‘self’] }} return_content=yes
    register: rancher_token

This is not working for me.

Any thoughts greatly appreciated.


1 Like

I would try to get it working with curl before adding an extra layer of Ansible on top. The post takes the project id in a json body, not a query param. And the registration url isn’t the self link of the token.