I changed the playbook and it runs ok.

  - name: Assign sat server {{server}} with id {{host.json.id}} to 
{{host_collection}} with id {{hc_id}}
    uri:
       url: "https://xxxxx/katello/api/host_collections/{{hc_id}}/add_hosts";
       user: "{{user}}"
       password: "{{password}}"
       method: PUT
       return_content: yes
       force_basic_auth: yes
       validate_certs: no
       body_format: json
       body: '{"host_ids":["{{host.json.id}}"]}'
       status_code: [200,201,202,204,301,401]

El martes, 23 de octubre de 2018, 14:58:31 (UTC+2), Alberto Jimenez Lozano 
escribió:
>
> It fails too.
>
>   - name: Assign sat server {{server}} to {{host_collection}}
>     uri:
>        url: "https://xxxx/katello/api/host_collections/586/add_hosts";
>        user: "{{user}}"
>        password: "{{password}}"
>        method: PUT
>        return_content: yes
>        force_basic_auth: yes
>        validate_certs: no
>        body_format: json
>        body: '{"host_ids":"[972]"}'
>        status_code: [200,201,202,204,301,401]
>
>     "json": {
>         "displayMessage": "undefined method `map' for 
> \"[972]\":String\nDid you mean?  tap", 
>         "errors": [
>             "undefined method `map' for \"[972]\":String\nDid you mean?  
> tap"
>         ]
>
> El martes, 23 de octubre de 2018, 13:44:48 (UTC+2), Brad Van Orden 
> escribió:
>>
>> Two things:
>>
>>
>>    1. Try removing the trailing slash in the url.
>>    2. Try: url: https://xxxx/katello/api/v2/host_collections/{{ hc_id 
>>    }}/add_systems 
>>    
>> <https://xxxx/katello/api/v2/host_collections/%7B%7Bhc_id%7D%7D/add_systems/>
>>
>> Haven't attempted the api with satellite yet.  So, don't have any direct 
>> experience.
>>
>> On Tuesday, October 23, 2018 at 4:34:44 AM UTC-4, Alberto Jimenez Lozano 
>> wrote:
>>>
>>> I'm working wit uri module  with satellite.
>>> I do one playbook for create a new host_collection and it works OK.
>>>
>>>
>>> - name: CREATE HC 
>>>     uri:
>>>        url: "https://xxxxxx/katello/api/host_collections/";
>>>        user: "{{user}}"
>>>        password: "{{password}}"
>>>        method: POST
>>>        return_content: yes
>>>        force_basic_auth: yes
>>>        validate_certs: no
>>>        body_format: json
>>>        body: '{"name":"{{hc}}","organization_id":"1"}'
>>>        status_code: [200,201,202]
>>>
>>> But I want to do a playbook to add/remove host from a host collection, 
>>> and the urls that appears in the api guides fails.
>>>
>>> For api v1  the api guide indicates use PUT 
>>> /katello/api/v2/host_collections/:id/add_systems
>>>
>>>
>>> https://access.redhat.com/documentation/en-us/red_hat_satellite/6.0/html/api_guide/add_systems_to_the_host_collection
>>>
>>>
>>>
>>> I did this playbooks and it fails:
>>>
>>>
>>> - name: Assign sat server {{server}} to {{host_collection}}
>>>     uri:
>>>        url: "
>>> https://xxxx/katello/api/v2/host_collections/{{hc_id}}/add_systems/";
>>>        user: "{{user}}"
>>>        password: "{{password}}"
>>>        method: PUT
>>>        return_content: yes
>>>        force_basic_auth: yes
>>>        validate_certs: no
>>>        body_format: json
>>>        body: '{"system_ids":"[972,1280]"}'
>>>        status_code: [200,201,202,204,301,401]
>>>
>>> The message error is 404 error
>>>
>>> The page you were looking for doesn't exist (404)
>>> The page you were looking for doesn't exist
>>>
>>> And the path https://xxxx/katello/api/v2/host_collections/{{hc_id}}/ 
>>> works OK.
>>>
>>>
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/981606b2-35c3-4066-82b4-5b958296e6aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to