# Playbook example
---
- name: Install IIS
hosts: all
gather_facts: false
tasks:
- name: Install IIS
win_feature:
name: "Web-Server"
state: absent
restart: yes
include_sub_features: yes
include_management_tools: yes
Interestingly, it appeared to *uninstall* IIS. I'm guessing it's because of the line "state: absent" (but I'm a newbie, so what do I know). So, then I decided to change "absent" to "present", and started to get this error:
Vault password:
sawintest01 | FAILED >> {
“failed”: true,
“msg”: “A parameter cannot be found that matches parameter name ‘IncludeManagementTools’.”
}
OK, so I removed the line “IncludeManagementTools”. Now, every time I run the playbook, I get the same error. And, if I create a new playbook to install, say SNMP, the same error is still generated, despite the fact that the line “IncludeManagementTools” isn’t in the playbook (or any playbooks, at this point). Huh? Why does Ansible keep whining about a parameter that I’m not even including? What am I doing wrong here?
I can’t explain the behaviour you are seeing but maybe some of the following will help.
Yes you are correct, state: absent is asking the module to ensure that IIS is not present.
You also have ‘restart: yes’ set. I don’t know off the top of my head if installing IIS requires a restart but perhaps the windows machine is restarting while you are attempting to run further playbooks (not sure if the module will wait for the restart to complete). That might account for some strange behaviour.
You can also run ansible-playbook -v to get ansible to be more verbose about what its doing. There are several levels of debug information so if -v doesn’t give any clues try -vvvvv
My guess would be that the file that is being run by ansible is not the same as the one you are editing. One trick I use to debug situations where I think my edits aren’t being noticed is to deliberately introduce a syntax error, so you could try deliberately breaking the yaml in your playbook.
I have used -vvvv to get as much debugging information as possible, and I presented it in my op. Only one instance of my playbook exists, and it doesn’t include the parameter ‘IncludeManagementTools’, though that was in the example playbook that I used from Puppet documentation. It’s like the original is cached somewhere and, if it is, I don’t know where that somewhere is. As I mentioned, if I use the parameter “state: absent”, the playbook works to uninstall the service if it’s installed. But it fails if I use the parameter “state: present”. Yeesh.
Ok, well I’m still mystified too, but here’s a few other thoughts.
Might be worth checking what is between the controller and the windows machine network wise in case there’s some proxying or something. Would still be very strange behaviour for a proxy to introduce though.
I notice you have
gather_facts: false
might be worth setting that to true and running with -v just to see if the facts that get gathered tally with what you expect about the windows machine.
Something else that might show a bit more information is if you set
ANSIBLE_KEEP_REMOTE_FILES=1
before running your playbook, it won’t remove the files transferred to the remote machine. From memory you’ll need -vvvv to see the location where the files are transferred to.
You can then at least see what powershell is being run, which might help figure out what is going on.
I think that the win_feature module is the culprit. Something to do with ‘IncludeManagementTools’ not being part of the Powershell Get-WindowsFeature command. Someone else posted about this issue last August, but doesn’t appear to have gotten a resolution response.