Ansible Playbook error: object has no attributes


(macmeaker) #1

Hey there,

at the moment I define a playbook in Ansible that creates some VMs and add the servers to Icinga2 via API. I use item loops:

  - name: Add droplets to monitoring
    uri:
      url: "https://XXX.XXX:5665/v1/objects/hosts/{{ item.name }}"
      headers:
        Accept: "application/json"
      method: PUT
      user: ansible
      password: XXXX
      body: '{ "templates": [ "generic-host" ], "attrs": { "address": "{{ item.droplet.ip_address }}", "check_command": "hostalive", "vars.os" : "Linux" } }'
      force_basic_auth: yes
      body_format: json
      validate_certs: False
    with_items: "{{droplet_details.results}}"
  - debug: msg= "{{ item.droplet.ip_address }}"
    with_items: "{{droplet_details.results}}"

The part without an item loop works fine but with this Items I receive the error message.

Is it possible to view the object attributes?

Maybe some of you can help me.

Thanks


(macmeaker) #2

I found the error. At the task before I didn’t filled the register because the state was “absent”.

Sorry