...

Ansible Windows установка программ

How to install an application on Windows by using Ansible playbook

To Install an Application on Windows by using Ansible playbook

Introduction:

Ansible is an open-source tool for managing software configurations and deploying applications. Chocolately is a management tool for Windows software.

Master Server Requirements:

Windows Requirements:

Installation Procedure:

Snap 1

Step 1: Search for chocolatey in browser

Step 2: Copy the installation command in chocolatey install page Snap 2Step 3: Run Powershell ISE as an administrator Snap 3

Step 4: Install chocolatey by using the following command

PS C:\WINDOWS\system32> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org) Getting latest version of the Chocolatey package for download. Not using proxy. Getting Chocolatey from https://community.chocolatey.org/api/v2/package/chocolatey/0.11.3. Downloading https://community.chocolatey.org/api/v2/package/chocolatey/0.11.3 to C:\Users\Admin\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip Not using proxy. Extracting C:\Users\Admin\AppData\Local\Temp\chocolatey\chocoInstall\chocolatey.zip to C:\Users\Admin\AppData\Local\Temp\chocolatey\chocoInstall Installing Chocolatey on the local machine Creating ChocolateyInstall as an environment variable (targeting 'Machine') Setting ChocolateyInstall to 'C:\ProgramData\chocolatey' WARNING: It's very likely you will need to close and reopen your shell before you can use choco. Restricting write permissions to Administrators We are setting up the Chocolatey package repository. The packages themselves go to 'C:\ProgramData\chocolatey\lib' (i.e. C:\ProgramData\chocolatey\lib\yourPackageName). A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin' and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'. 

Step 5: Check the OS version by using the following command

root@linuxhelp:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 21.04 Release: 21.04 Codename: hirsute 

Step 6: Check the availability of Ansible package

root@linuxhelp:~# apt list -a ansible Listing. Done ansible/hirsute,hirsute,now 4.8.0-1ppa~hirsute all [installed] ansible/hirsute,hirsute 2.10.7-1 all 

Step 7: Check the availability of python3-pip package

root@linuxhelp:~# apt list -a python3 Listing. Done python3/hirsute,now 3.9.4-1 amd64 [installed,automatic] python3/hirsute 3.9.4-1 i386 

Step 8: Check the availability of python package pywinrm

root@linuxhelp:~# pip list | grep pywinrm pywinrm 0.4.2 ansible_winrm_server_cert_validation=ignore 

Step 9: Install the plugins of chocolatey for ansible

root@linuxhelp:~# ansible-galaxy collection install chocolatey.chocolatey Starting galaxy collection install process Nothing to do. All requested collections are already installed. If you want to reinstall them, consider using `--force`. 

Step 10:Create inventory for Windows node system

root@linuxhelp:~# vi /etc/ansible/hosts [windows] 192.168.2.134 [windows:vars] ansible_user=Admin ansible_password=Admin@123 ansible_port=5986 ansible_connection=winrm 

Step 11:Create playbook for installing namecoin application

root@linuxhelp:~# vi install.yml hosts: windows gather_facts: true tasks: - name: install namecoin win_chocolatey: name: namecoin state: present 

Step 12: Check the syntax of the install.yml ansible playbook by using the following command

root@linuxhelp:~# ansible-playbook install.yml --syntax-check playbook: proxyset.yml 

Step 13: Run the install.yml playbook by using the following command

root@linuxhelp:~# ansible-playbook install.yml PLAY [windows] ************************************************************************************** TASK [Gathering Facts] ****************************************************************************** ok: [192.168.2.134] TASK [install namecoin] ***************************************************************************** changed: [192.168.2.134] PLAY RECAP ****************************************************************************************** 192.168.2.134 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 

Snap 4

Step 14 : Namecoin application installed on Windows Client system

Step 15: Create playbook for uninstall namecoin application

root@linuxhelp:~# vi uninstall.yml - hosts: windows gather_facts: true tasks: - name: Uninstall namecoin win_chocolatey: name: namecoin state: absent ~ 

Step 16: Check the syntax of the uninstall.yml ansible playbook by using the following command

root@linuxhelp:~# ansible-playbook uninstall.yml --syntax-check playbook: removeproxy.yml 

Step 17: Run the uninstall.yml playbook by using the following command

root@linuxhelp:~# ansible-playbook uninstall.yml PLAY [windows] ************************************************************************************** TASK [Gathering Facts] ****************************************************************************** ok: [192.168.2.134] TASK [Uninstall namecoin] *************************************************************************** changed: [192.168.2.134] PLAY RECAP ****************************************************************************************** 192.168.2.134 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 

Snap 5

Step 18: Namecoin application Uninstalled on Windows Client system

With this installation of an application on Windows by using Ansible comes to an end

Install Windows software – Ansible module win_chocolatey

How to Install Windows software with Ansible? Today I’m going to reveal a secret to installing software in a Windows managed host using Chocolatey Package Manager.

September 8, 2021

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to Install Windows software with Ansible?

Today I’m going to reveal a secret to installing the software in a Windows-managed host using Chocolatey Package Manager. I’m Luca Berton and welcome to today’s episode of Ansible Pilot

Ansible module win_chocolatey

Chocolatey is the package manager for windows, it has the largest online registry of Windows packages. At the moment it contains nearly 9000 Community Maintained Packages. Today we’re talking about Ansible module win_chocolatey to automate the software installation process. The full name is chocolatey.chocolatey.win_chocolatey, which means that is part of the collection distributed by “chocolatey”. It manages packages in Windows using chocolatey. It’s the windows correspondent of the ansible package module.

Parameters

  • name liststring – the name of the package
  • state string – present / latest /absent /downgrade /reinstalled
  • version string – specific version
  • pinned boolean – no/yes
  • source string – URL/path

The parameter list is pretty wide but this four are the most important options. In the “name” parameter you are going to specify the name of the package or a list of packages. If you would like to install a specific version you could specify it in the “version” parameter. The state specifies the action that we would like to perform. In our case for install is “present or latest”. I’d like to mention some additional parameters that might be useful for you. The “pinned” parameter allows to pin the Chocolatey package or not. Pin a package to suppress upgrades. During the next upgrade for all packages, Chocolatey will automatically skip the pinned packages. “source” allows specifying a local repository for packages if available.

The Best Resources For Ansible

Video Course

Printed Book

eBooks

  • Ansible by Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
  • Ansible For Windows By Examples: 50+ Automation Examples For Windows System Administrator And DevOps
  • Ansible For Linux by Examples: 100+ Automation Examples For Linux System Administrator and DevOps
  • Ansible Linux Filesystem By Examples: 40+ Automation Examples on Linux File and Directory Operation for Modern IT Infrastructure
  • Ansible For Containers and Kubernetes By Examples: 20+ Automation Examples To Automate Containers, Kubernetes and OpenShift
  • Ansible For Security by Examples: 100+ Automation Examples to Automate Security and Verify Compliance for IT Modern Infrastructure
  • Ansible Tips and Tricks: 10+ Ansible Examples to Save Time and Automate More Tasks
  • Ansible Linux Users & Groups By Examples: 20+ Automation Examples on Linux Users and Groups Operation for Modern IT Infrastructure
  • Ansible For PostgreSQL by Examples: 10+ Examples To Automate Your PostgreSQL database
  • Ansible For Amazon Web Services AWS By Examples: 10+ Examples To Automate Your AWS Modern Infrastructure
  • Ansible Automation Platform By Example: A step-by-step guide for the most common user scenarios

demo

Are you ready to make your hands dirty? Let’s jump in a quick live demo of a playbook about the win_chocolatey module.

  • win_chocolatey.yml
--- - name: win_chocolatey module demo  hosts: all  become: false  gather_facts: false  vars:  - packages:  - git  - notepadplusplus  tasks:  - name: install packages  chocolatey.chocolatey.win_chocolatey:  name: ">"  state: present 

Recap

Now you know better the Ansible module win_chocolatey and how you could use it successfully in your playbook to automate your day-to-day activities. Subscribe to the YouTube channel, Medium, Website, Twitter, and Substack to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Donate

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

See Also

Ansible troubleshooting - chgrp failed

Ansible troubleshooting – chgrp failed

When you try to change permission to file your Ansible Playbook might end up with “chgrp failed” error. Let’s investigate together why this error happens and how to solve it!

Change file permission - Ansible module file

Change file permission – Ansible module file

How to change file or directory permission with Ansible? I’m going to show you a live demo and some simple Ansible code to change chmod and group of a test.txt file.

Open firewall ports in Debian like systems — Ansible module ufw

Open firewall ports in Debian like systems — Ansible module ufw

How to open firewall HTTP and HTTPS ports in Debian-like systems using Ansible and ufw, the Uncomplicated Firewall. I’m going to show you a live demo and some simple Ansible code: Debian, Ubuntu, Linux Mint, MX Linux, Deepin, AntiX, PureOS, Kali Linux, Parrot OS, Devuan, Knoppix, AV Linux Linux

Open firewall ports in RedHat-like systems - Ansible module firewalld

Open firewall ports in RedHat-like systems – Ansible module firewalld

How to open HTTP and HTTPS firewall ports in RedHat-like systems with Ansible. I’m going to show you a live demo and some simple Ansible code: RedHat Enterprise Linux, CentOS, CentOS Stream, Fedora, ClearOS, Oracle Linux, EuroLinux, Fermi Linux, EulerOS, ROSA Linux, Springdale Linux, Asianux

При подготовке материала использовались источники:
https://www.linuxhelp.com/how-to-install-an-application-on-windows-by-using-ansible-playbook
https://www.ansiblepilot.com/articles/install-windows-software-ansible-module-win-chocolatey/

Добавить комментарий