summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_user_profile/tasks/main.yml
blob: c37d219df348f77a44a23bd776193d7a30b5f925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- name: set custom user facts
  set_fact:
    test_username: ansible_test
    test_password: '{{ "password123!" + lookup("password", "/dev/null chars=ascii_letters,digits length=9") }}'

- name: create test account
  win_user:
    name: '{{ test_username }}'
    password: '{{ test_password }}'
    state: present
  register: test_username_info

- block:
  - name: check if profile exists
    win_stat:
      path: C:\temp\{{ test_username }}
    register: profile_path

  - name: assert that profile doesn't exist before the test
    assert:
      that:
      - not profile_path.stat.exists

  - name: run tests
    include_tasks: tests.yml

  always:
  - name: remove test account
    win_user:
      name: '{{ test_username }}'
      state: absent

  - name: remove test account profile
    win_user_profile:
      name: '{{ item }}'
      state: absent
      remove_multiple: True
    with_items:
    - '{{ test_username }}'
    - '{{ test_username }}.000'
    - test_username_profile