Automating Windows tasks with Ansible
A list of the Windows modules included with Ansible 4.3 is available at the following link, and it must be noted that, although you can use all the familiar Ansible constructs with Windows hosts such as vars
, handlers
, and blocks
, you must use Windows-specific modules when defining tasks. The introduction of collections means it is quite easy to locate them, and the ansible.windows
collection is a great place to start. This contains all the Windows-specific modules you were used to using in Ansible 2.9 and earlier: https://docs.ansible.com/ansible/latest/collections/index_module.html#ansible-windows.
In this part of the chapter, we will run through a few simple examples of Windows playbooks to highlight a few of the things you need to know when writing playbooks for Windows.
Picking the right module
If you were running Ansible against a Linux server, and wanted to create a directory and then copy a file into it, you would use the...