Is it possible to create an IIS Application Pool that uses a custom identity with Ansible?
I asked the question on the Ansible forums and got the following response.
- Create the Application Pool first using “win_iis_webapppool“
- Then switch the pools Identity using module “win_command” and the “appcmd.exe” command.
Here are the results and notes from my implementation.
- Create playbook that creates pool and then updates (Example below)
- —
– hosts: windows
remote_user: buildadmin
tasks:
– name: Create new application pool
win_iis_webapppool:
name: “{{ apppool }}”
state: started
attributes: ‘managedRuntimeVersion:v4.0|autoStart:false’
– name: Update application pool identity
win_command: ‘C:\Windows\System32\inetsrv\appcmd set config /section:applicationPools /[name=”{{ apppool }}”].processModel.identityType:SpecificUser /[name=”{{ apppool }}”].processModel.userName:buildadmin /[name=”{{ apppool }}”].processModel.password:myPassword’
- —
- Run the playbook against my windows machines with a command line variable
- ansible-playbook -v installWebsiteApplication.yml -i hosts –extra-vars “apppool=devopsWebsite_1_1_2017”