# Microsoft.ad.computer - adding spn results in "New-ADComputer failed: The specified account already exists"

**URL:** <https://forum.ansible.com/t/microsoft-ad-computer-adding-spn-results-in-new-adcomputer-failed-the-specified-account-already-exists/1910>\
**Category:** Get Help\
**Created:** [October 24, 2023, 11:56am UTC](https://forum.ansible.com/t/microsoft-ad-computer-adding-spn-results-in-new-adcomputer-failed-the-specified-account-already-exists/1910 "2023-10-24T11:56:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LDW](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@LDW](https://forum.ansible.com/u/LDW)\
**Post date:** [October 24, 2023, 11:56am UTC](https://forum.ansible.com/t/microsoft-ad-computer-adding-spn-results-in-new-adcomputer-failed-the-specified-account-already-exists/1910/1 "2023-10-24T11:56:16Z")

</div>

Hi!

I’m using ansible core 2.14.2 on a RedHat 8 virtual machine.  
When I install a server with vRealize Automation, it will start a playbook that will do some basic stuff on the new vm like creating folders, adding the server to the domain, install some software etc.  
I want to add an spn for the server as well and I use this task for it:

- name: Add SPNs to computer  
microsoft.ad.computer:  
name: “{{hostname}}”  
domain\_server: “{{domain}}”  
domain\_username: “{{user}}”  
domain\_password: “{{ lookup(‘file’, ‘vars/{{domainshort}}’) }}”  
spn:  
add:  
- “TERMSRV/{{hostname}}.{{domain}}”

In 90% of our installs, it works but sometimes I get the following error:

TASK [Add SPNs to computer] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*,fatal: [\ ***servername**]: FAILED! =\> {“changed”: false, “distinguished\_name”: null, “msg”: “New-ADComputer failed: The specified account already exists”, “object\_guid”: null},PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*, **servername** : ok=16 changed=12 unreachable=0 failed=1 skipped=7 rescued=0 ignored=0

In some cases, the spn already exists indeed so I remove the server, remove the spn and remove the computer object, run the deploy again and it works.

Now I have a server where the spn does not exists, double checked by the AD team as well and it throws the error. The weird thing about it is that it says New-ADComputer but I only add the spn so I expect to see Set-ADComputer.  
The AD team does not want me to use set instead of add spn because a few spns are created by default when adding the server in the domain.

I just don’t get it that for 90% of our deploys it works, 9% throws an error but is fixed with removing the SPN and that 1% does not want to install no matter what even if the spn did not exist yet.

Maybe someone has an idea I did not think of? Keep in mind, I’m not a linux person nor ansible person so if you have something I need to check, please explain me like I’m 5 😄
