Ansible Install Admin Tools via “win_chocolatey” module.
I create playbook to install some Admin tools on my windows server.
– 7zip (program to zip and unzip big files)
– procexp (program to investigate performance issues)
– putty ( program to connect via port 22)
– notepadplusplus (advance notepad)
– windirstat (program to investigate disk space issues)
– git ( github program )
– winscp ( program to copy file )
For this playbook I use module call chocolatey.chocolatey.win_chocolatey.
You can read some information on Ansible documentation.
https://docs.ansible.com/ansible/latest/collections/chocolatey/chocolatey/win_chocolatey_module.html
To install it use: ansible-galaxy collection install chocolatey.chocolatey
.
To use it in a playbook, specify: chocolatey.chocolatey.win_chocolatey
.
download playbook >>InstallSoftWindows
OPTION 1 (Run playbook from you ansible server)
- I run this playbook by type command ansible-playbook ansible InstallSoftWindows.yml
2. Test
When this playbook finish I was simply login to server and check if all programs was installed.
Just putty you can find in in start menu as usually 🙂
OPTION 2 (run from Ansible Tower )
download playbook for Ansible Tower >> InstallSoftWindowsAT
Let’s create Template in Ansible Tower to run playbook.
Important
Modify playbook module name need to be change from chocolatey.chocolatey.win_chocolatey to win_chocolatey
I get some error when I try run with chocolatey.chocolatey.win_chocolatey module
- Copy Playbook
I copy playbook to my project folder in Ansible Tower in my case this was /var/lib/awx/projects/WindowsScripts
If you have any YML scripts you can copy to project folder “/var/lib/awx/projects/your project folder name”
you need to select *Name, Job Type, *Inventory, *Project, *Playbook this will be different depend how you configure your Ansible Tower.
2. Create New template select Name, Inventory, Project, Playbook and save option.
3. Check and edit your ansible tower host inventory if needed.
4. Run Templates.
5. Check results.
MORE EXAMPLES
- name: Install git win_chocolatey: name: git state: present - name: Upgrade installed packages win_chocolatey: name: all state: latest - name: Install notepadplusplus version 6.6 win_chocolatey: name: notepadplusplus version: '6.6' - name: Install notepadplusplus 32 bit version win_chocolatey: name: notepadplusplus architecture: x86 - name: Install git from specified repository win_chocolatey: name: git source: https://someserver/api/v2/ - name: Install git from a pre configured source (win_chocolatey_source) win_chocolatey: name: git source: internal_repo - name: Ensure Chocolatey itself is installed and use internal repo as source win_chocolatey: name: chocolatey source: http://someserver/chocolatey - name: Uninstall git win_chocolatey: name: git state: absent - name: Install multiple packages win_chocolatey: name: - procexp - putty - windirstat state: present - name: Install multiple packages sequentially win_chocolatey: name: '{{ item }}' state: present loop: - procexp - putty - windirstat - name: Uninstall multiple packages win_chocolatey: name: - procexp - putty - windirstat state: absent - name: Install curl using proxy win_chocolatey: name: curl proxy_url: http://proxy-server:8080/ proxy_username: joe proxy_password: p@ssw0rd - name: Install a package that requires 'become' win_chocolatey: name: officepro2013 become: yes become_user: Administrator become_method: runas - name: install and pin Notepad++ at 7.6.3 win_chocolatey: name: notepadplusplus version: 7.6.3 pinned: yes state: present - name: remove all pins for Notepad++ on all versions win_chocolatey: name: notepadplusplus pinned: no state: present
Please Subscribe