---
#- hosts: all
#  connection: local  # execute modules on controller
#  gather_facts: no
#  module_defaults:
#    - name: Example
#      ansibleguy.opnsense.alias:
#        firewall: "{{ ansible_host }}"
#        api_credential_file: "./opnsense.key"
#
#    tasks:
#    - name: Example
#      ansibleguy.opnsense.alias:
#        name: 'ANSIBLE_TEST1'
#        content: ['1.1.1.1']

- name: Get list of users from OPNsense
  hosts: localhost
  gather_facts: no

  tasks:
    - name: Retrieve users
      uri:
        url: "{{ opnsense_url }}/api/system/user"
        method: GET
        headers:
          Authorization: "Bearer {{ api_key }}"
          Content-Type: "application/json"
        validate_certs: no
      register: users_response

    - name: Display list of users
      debug:
        msg: "{{ users_response.json }}"

