---
- name: Make an HTTPS API call with basic auth
  hosts: localhost
  gather_facts: no

  tasks:
    - name: Enable network booting via API
      uri:
        #url: "{{ API_URL }}/dhcpv4/service/reconfigure?if=lan"
        #url: "{{ API_URL }}/dhcpv4/service/start"
        url: "{{ API_URL }}/dhcpv4/service/reconfigure"
        method: POST
        user: "{{ API_KEY }}"
        password: "{{ API_SECRET }}"
        force_basic_auth: yes
        headers:
          Content-Type: "application/json"
        body: >
          {
              "enable": "no",
              "submit": "Save",
              "if": "lan"
          }
        body_format: json
        validate_certs: no
        return_content: yes
      register: api_response

    - name: Print API response
      debug:
        var: api_response.content

#          {
#            "interface": "lan",
#            "next-server": "{{ tftp_server_ip }}",
#            "filename": "{{ bootfile }}",
#            "root-path": "{{ root_path }}"
#          }
#
#        body: >
#          {
#            "lan": {
#              "enable": "yes",
#              "submit": "Save",
#              "if": "lan"
#            }
#          }
