THE GAME HAS CHANGED

Introducing Infoblox Universal DDI ManagementTM

Watch the launch to discover the new era of management for critical network services. Watch Now

API & Integration, DevOps,NetOps,SecOps

Reply

Add CAA Record Using Ansible URI module

[ Edited ]
Authority
Posts: 18
1439     0

I'm trying to add a CAA recording using Ansible but I don't see a module for this so I'm trying to add the record using the Ansible URI module.  It works when I use postman but fails using Ansible with a Bad Request error.  I have also tried a simple GET from an example from Infoblox and it also fails.  Not sure why.  Here's my code for the simple GET request for a member.

 

- name: Add CAA Record
  hosts: Infoblox
  collections: 
   - infoblox.nios_modules
  connection: local
  gather_facts: false
  vars_files: 
    - defaults/main.yml

  tasks:

    - name: Get object reference of the DNS service
      uri:
        url: https://GRD02NODE1.site/wapi/v2.11.2/member:dns?host_name=dns.net
        user: "{{ nios_provider.username }}"
        password: "{{ nios_provider.password }}"
        validate_certs: no
        return_content: yes
        method: GET
        force_basic_auth: yes
        status_code: 200
      register: content

This is the error:
    "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request",
    "redirected": false,
    "referrer_policy": "no-referrer-when-downgrade",
    "status": 400,
    "strict_transport_security": "max-age=31536000; includeSubDomains",
    "url": "https://GRD02NODE1.site/wapi/v2.11.2/member:dns?host_name=dns.net",
    "x_content_type_options": "nosniff",
    "x_frame_options": "SAMEORIGIN",
    "x_xss_protection": "1; mode=block"

 

Re: Add CAA Record Using Ansible URI module

Superuser
Posts: 17
1439     0

Have you tried specifically setting the accept-header to application/json?, i.e.

 

- name: Get object reference of the DNS service
      uri:
        url: https://GRD02NODE1.site/wapi/v2.11.2/member:dns?host_name=dns.net
        user: "{{ nios_provider.username }}"
        password: "{{ nios_provider.password }}"
        validate_certs: no
        return_content: yes
        method: GET
        headers:
          Accept: application/json
        force_basic_auth: yes
        status_code: 200
      register: content 

 

Re: Add CAA Record Using Ansible URI module

New Member
Posts: 2
1440     0

I realize this is a late reply but if you're still stuck, I always place quotes around the URL value in the URI definition in the playbook.  That may be what is creating the bad request.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You