---
- name: Ansible resource module example for sonic_aaa
  hosts: datacenter
  gather_facts: False
  connection: httpapi
  collections:
    - dellemc.enterprise_sonic
  tasks:
    - name: delete all users
      sonic_users:
        config:
        state: deleted
    - name: delete all aaa
      sonic_aaa:
        config:
        state: deleted
    - name: delete all tacacs servers
      sonic_tacacs_server:
        config:
        state: deleted
    - name: delete all radius servers
      sonic_radius_server:
        config:
        state: deleted
    - name: Merge users configurations
      sonic_users:
        config:
          - name: sysadmin
            role: admin
            password: admin
            update_password: always
          - name: sysoperator
            role: operator
            password: operator
            update_password: always
        state: merged
    - name: Test SONiC aaa
      sonic_aaa:
        config:
          authentication:
            data:
              fail_through: true
              group: tacacs+
              local: true
        state: merged
    - name: Merge tacacs configurations
      sonic_tacacs_server:
        config:
          auth_type: pap
          key: pap
          source_interface: Eth 1/2
          timeout: 10
          servers:
            host:
              - name: 1.2.3.4
                auth_type: pap
                key: 1234
        state: merged
    - name: Merge radius configurations
      sonic_radius_server:
        config:
          auth_type: chap
          key: chap
          nas_ip: 1.2.3.4
          statistics: true
          timeout: 10
          retransmit: 3
          servers:
            host:
              - name: localhost
                auth_type: mschapv2
                key: local
                priority: 2
                port: 52
                retransmit: 2
                timeout: 20
                source_interface: Eth 1/2
                vrf: mgmt
        state: merged
