How to connect to Rally from Ansible

128 Views Asked by At

I am trying to connect to Rally from Ansible. For this I am using uri module and also created an API key from Rally. My task:-

  tasks:

    - name: Get data
      uri:
        url: 'https://rally1.rallydev.com/slm/webservice/v2.0/subscription'
     #   headers:
      #    api_key: "myapikey"
        user: myapikey
        password:
        follow_redirects: all
        return_content: yes
        status_code: 200
        method: GET
      register: get_data

    - debug: var=get_data

But I am still getting error:-

"msg": "Status code was 401 and not [200]: HTTP Error 401: Full authentication is required to access this resource",

Not sure what I am doing wrong.

1

There are 1 best solutions below

0
NotApplicable On

A simple way to prove that you have access would be to use curl on the command line and then script it via your favourite language to do something similar to the following:

curl --config options.txt

Where options.txt contains:

url https://rally1.rallydev.com/slm/webservice/v2.0/workspace?query=&fetch=true&start=1&pagesize=20

header = "ZSESSIONID: YOURAPIKEY"

You will see that the API key is used in a header variable ZSESSIONID. It works on my machine.....