---
- name: create test group that has a network logon denied
  win_group:
    name: win_user-test
    state: present

- name: add test group to SeDenyNetworkLogonRight
  win_user_right:
    name: SeDenyNetworkLogonRight
    users:
    - win_user-test
    action: add

- block:
  - name: run tests
    include_tasks: tests.yml

  always:
  - name: remove SeDenyNetworkLogonRight on test group
    win_user_right:
      name: SeDenyNetworkLogonRight
      users:
      - win_user-test
      action: remove

  - name: remove test group
    win_group:
      name: win_user-test
      state: absent

  - name: remove the test user
    win_user:
      name: '{{ test_win_user_name }}'
      state: absent
