Hi everyone,
I apologise, I am new to Ansible and this is rather open ended.
After extensive use of the documentation I have my inventory, vars, vault and playbook all working together. However, there is room for improvement.
This is my simple proof of concept playbook:
`
Well to get rid the warning, remove the "{{ and }} " from your ‘when’ clause. The ‘when’ directive is a bit different from other places where you use jinja2 expressions as the “{{ and }}” are implicit. Although this might seem a bit inconsistent, it does result in easier to read tasks.
If you only want to reboot when a reboot is really needed, you are best off converting your scripts into ansible modules. You can either keep this to yourself or go the extra yards and make a PR to contribute them back to ansible. Script is great for quick-and-dirty get things done, but proper modules detect the existing state of resources and then return whether or not they are changed. If you are lucky and powershell gives you a decent way to get at the state, sometimes modules can be pretty small - there are some that are less than 50 lines of code. Have a look in https://github.com/ansible/ansible/tree/devel/lib/ansible/modules/windows/ plenty of examples to get you started.
Sometimes its not worth the effort of course. But if you do create modules and make their parameters described the desired state you need (rather than making them action or command oriented), then you are definitely going with the grain of how ansible is supposed to work and you will gain the benefit of more easily readable playbooks.
Hope this helps,
Jon
Hi Jon,
The link you provided has worked wonders, I have found ‘win_feature’ module does more than I need.