Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The differentiation between accounts seems not very idempotent #582

Open
MaKaNu opened this issue Sep 13, 2024 · 0 comments
Open

The differentiation between accounts seems not very idempotent #582

MaKaNu opened this issue Sep 13, 2024 · 0 comments

Comments

@MaKaNu
Copy link

MaKaNu commented Sep 13, 2024

SUMMARY

The module win_user_profile differentiates between already deleted and still existent accounts. This causes issues if the user never existed.

As an example, the user "user1" never existed on one system. If I run the module with name and state: absent I get the following error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: bei <ScriptBlock>, <Keine Datei>: Zeile 100
failed: [one_system] (item=user1) => {"ansible_loop_var": "item", "changed": false, "item": "user1", "msg": "Unhandled exception while executing module: Die Eigenschaft ProfileImagePath ist im Pfad HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\S-1-5-21-1677214107-1252868271-91609288-4038 nicht vorhanden."}

If I run with username and state: absent the output depends on the state of the account. Either the account still exists, but the profile is already deleted, then the status is OK if the user still exists and the profile also the status is CHANGED. If the user never existed the status is FAILED with following result:

failed: [one_system] (item=user1) => {"ansible_loop_var": "item", "changed": false, "item": "user1", "msg": "argument for username is of type System.String and we were unable to convert to sid: Manche oder alle Identitätsverweise konnten nicht übersetzt werden."}

Maybe I just overshoot my approach since I want to delete the accounts completely and running win_user and win_user_profile with status: absent is kind of redundant, but I think this module should always run with OK if the user and the user profile is absent and with CHANGED if the user is absent but the profile is not.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.windows.win_user_profile

ANSIBLE VERSION
ansible [core 2.17.1]
  config file = /home/matti.kaupenjohann/Dokumente/ansible/laptopcart-a315/ansible.cfg
  configured module search path = ['/home/matti.kaupenjohann/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/matti.kaupenjohann/Dokumente/ansible/ansible-software/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = /home/matti.kaupenjohann/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/matti.kaupenjohann/Dokumente/ansible/ansible-software/.venv/bin/ansible
  python version = 3.12.4 (main, Jun  7 2024, 06:33:07) [GCC 14.1.1 20240522] (/home/matti.kaupenjohann/Dokumente/ansible/ansible-software/.venv/bin/python)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION

CONFIGURATION
Collection        Version
----------------- -------
community.windows 2.2.0  
OS / ENVIRONMENT

Windows 10 build: 19045.4651

STEPS TO REPRODUCE
  1. Create a System with user user1
  2. run the playbook below
  3. run the playbook a second time
  4. repeat step 1 to 3 for second playbook

PB1

- name: Delete Users with Profiles
  hosts: all

  tasks:
    - name: Delete Profile user1
      community.windows.win_user_profile:
        username: user1
        state: absent

    - name: Ensure Accounts are deleted
      ansible.windows.win_user:
        name: 
        state: absent

PB2

- name: Delete Users with Profiles
  hosts: all

  tasks:
    - name: Delete Profile user1
      community.windows.win_user_profile:
        user: user1
        state: absent

    - name: Ensure Accounts are deleted
      ansible.windows.win_user:
        name: 
        state: absent
EXPECTED RESULTS

The Playbooks run with CHANGED for the first run and with OK for the second time

ACTUAL RESULTS

The Playbook 1 runs with CHANGED for the first time and with FAILED for second time.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant