Generating a registration token for Ansible automation

Hi,

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
    method=GET
    status_code=200
    url=“http://<host_redacted>:8080/v1/projects” return_content=yes
    register: project_id

  • name: Return the registration token URL of Rancher server
    action: uri
    method=POST
    status_code=201
    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
    method=GET
    url={{ rancher_token_url.json[‘links’][‘self’] }} return_content=yes
    register: rancher_token

This is not working for me.

Any thoughts greatly appreciated.

Jeff

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.