Ansible For Windows By Examples
By Berton
()
About this ebook
Ansible is a popular open-source IT automation technology for scripting applications in a wide variety of domains.
It is free, portable, powerful, and remarkably easy and fun to use.
This book is a tool to learn the Ansible automation technology with some real-life examples.
Whenever you are new to automation or a professional
Berton
Luca Berton is an Ansible Automation Engineer of Red Hat, based in Brno - Czech Republic. With more than 15 years of experience as a System Administrator, he has strong expertise in Infrastructure Hardening and Automation. Enthusiast of the Open Source supports the community sharing his knowledge in different events of public access. Geek by nature, Linux by choice, Fedora of course.
Read more from Berton
Ansible For Containers and Kubernetes By Examples Rating: 0 out of 5 stars0 ratingsAnsible For Security by Examples Rating: 0 out of 5 stars0 ratings
Related to Ansible For Windows By Examples
Related ebooks
Ansible DevOps Cookbook Rating: 0 out of 5 stars0 ratingsNginx Troubleshooting Rating: 0 out of 5 stars0 ratingsBuild Serverless Apps on Kubernetes with Knative: Build, deploy, and manage serverless applications on Kubernetes (English Edition) Rating: 0 out of 5 stars0 ratingsLearn Kubernetes - Container orchestration using Docker: Learn Collection Rating: 4 out of 5 stars4/5IT Infrastructure Automation Using Ansible: Guidelines to Automate the Network, Windows, Linux, and Cloud Administration Rating: 0 out of 5 stars0 ratingsAnsible For Linux by Examples Rating: 0 out of 5 stars0 ratingsHands-on Ansible Automation: Streamline your workflow and simplify your tasks with Ansible (English Edition) Rating: 0 out of 5 stars0 ratingsLearn Microservices - ASP.NET Core and Docker Rating: 0 out of 5 stars0 ratingsLearn Kubernetes & Docker - .NET Core, Java, Node.JS, PHP or Python Rating: 0 out of 5 stars0 ratingsYour First Week With Node.js Rating: 0 out of 5 stars0 ratingsVagrant Virtual Development Environment Cookbook Rating: 5 out of 5 stars5/5Web Programming with Go Rating: 0 out of 5 stars0 ratingsPodman in Action: Secure, rootless containers for Kubernetes, microservices, and more Rating: 0 out of 5 stars0 ratingsKubernetes A Complete Guide Rating: 0 out of 5 stars0 ratingsCI/CD Pipeline with Docker and Jenkins: Learn How to Build and Manage Your CI/CD Pipelines Effectively (English Edition) Rating: 0 out of 5 stars0 ratingsRed Hat Enterprise Linux 6 Administration: Real World Skills for Red Hat Administrators Rating: 0 out of 5 stars0 ratingsDocker Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsTerraform for Developers Rating: 0 out of 5 stars0 ratingsDocker, Containers And All The Rest: First Edition, #1 Rating: 0 out of 5 stars0 ratingsGetting Started with Istio Service Mesh: Manage Microservices in Kubernetes Rating: 0 out of 5 stars0 ratingsDocker: Build, Test, And Deploy Applications Fast Rating: 0 out of 5 stars0 ratingsMastering Ansible: A Comprehensive Guide Rating: 0 out of 5 stars0 ratingsLearning CoreOS Rating: 0 out of 5 stars0 ratingsSchematron: A language for validating XML Rating: 0 out of 5 stars0 ratingsKubernetes A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratings
System Administration For You
CompTIA A+ Complete Review Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5The Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsCybersecurity: The Beginner's Guide: A comprehensive guide to getting started in cybersecurity Rating: 5 out of 5 stars5/5Practical Data Analysis Rating: 4 out of 5 stars4/5Linux Bible Rating: 0 out of 5 stars0 ratingsNetworking for System Administrators: IT Mastery, #5 Rating: 5 out of 5 stars5/5Linux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsBash Command Line Pro Tips Rating: 5 out of 5 stars5/5PowerShell: A Comprehensive Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Wordpress 2023 A Beginners Guide : Design Your Own Website With WordPress 2023 Rating: 0 out of 5 stars0 ratingsLearn SQL Server Administration in a Month of Lunches Rating: 3 out of 5 stars3/5Learning ServiceNow Rating: 5 out of 5 stars5/5PowerShell: A Beginner's Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Learn PowerShell Scripting in a Month of Lunches Rating: 0 out of 5 stars0 ratingsEthical Hacking Rating: 4 out of 5 stars4/5Git Essentials Rating: 4 out of 5 stars4/5Operating Systems DeMYSTiFieD Rating: 0 out of 5 stars0 ratingsMastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5Learning Microsoft Endpoint Manager: Unified Endpoint Management with Intune and the Enterprise Mobility + Security Suite Rating: 0 out of 5 stars0 ratingsMastering Linux Network Administration Rating: 4 out of 5 stars4/5Linux: A complete guide to Linux command line for beginners, and how to get started with the Linux operating system! Rating: 0 out of 5 stars0 ratingsInstant Ubuntu Rating: 4 out of 5 stars4/5Basics with Windows Powershell Rating: 0 out of 5 stars0 ratings
Reviews for Ansible For Windows By Examples
0 ratings0 reviews
Book preview
Ansible For Windows By Examples - Berton
Ansible For Windows By Examples
30+ Automation Examples For Windows System Administrator And DevOps
Luca Berton
This book is for sale at http://leanpub.com/ansibleforwindowsbyexamples
This version was published on 2022-04-08
publisher's logo* * * * *
This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do.
* * * * *
© 2022 Luca Berton
ISBN for EPUB version: 978-80-908536-1-4
ISBN for MOBI version: 978-80-908536-2-1
Table of Contents
Introduction
Whois Luca Berton
Ansible For Beginners With Examples
What is Ansible
Getting Started
Inventory
Playbook
Variables
Facts and Magic Variables
Vault
Conditional
Loop
Handler
Role
Ansible Best Practices
Install Ansible
Ansible terminology - ansible vs ansible-core packages
How to install Ansible in Windows 10 WSL Windows Subsystem for Linux - Ansible install
How to install Ansible in Windows 11 WSL Windows Subsystem for Linux
How to install Ansible with PIP
Ansible Playbook Code for Windows
Configure a Windows Host for Ansible - ansible winrm
Test Windows host availability - Ansible module win_ping
Create an empty file in Windows-like systems - Ansible module win_file
Check if a file exists on Windows-like systems - Ansible module win_stat
Install Windows software - Ansible module win_chocolatey
Copy files to Windows remote hosts - Local to Remote - Ansible module win_copy
Copy files from Windows remote hosts - Ansible module fetch
Reboot Windows hosts - Ansible module win_reboot
Install Google Chrome in Windows-like systems - Ansible module win_chocolatey
Extract an archive in Windows-like systems - Ansible module win_unzip
Download a file in Windows-like systems - Ansible module win_get_url
Create a directory on Windows-like systems - Ansible module win_file
Check if a directory exists on Windows-like systems - Ansible module win_stat
Check Registry .NET Framework version on Windows-like systems - Ansible module win_reg_stat
Rolling Update Windows-like systems - Ansible module win_updates
Add Windows Registry on Windows-like systems - Ansible module win_regedit
Remove Windows Registry path or key on Windows-like systems - Ansible module win_regedit
Create a local group on Windows-like systems - Ansible module win_group
Remove a local group on Windows-like systems - Ansible module win_group
Create a local user on Windows-like systems - Ansible module win_user
Change local user password on Windows-like systems - Ansible module win_user
Backup With Robocopy on Windows - Ansible module win_robocopy
Ansible modules - win_command vs win_shell
Ansible Troubleshooting The Most Common Errors
Ansible troubleshooting - PowerShell incompatible with the sudo become plugin
Ansible troubleshooting - Windows 10 Error 0x80370102 WSL: Windows Subsystem for Linux
Ansible troubleshooting - Windows 11 Error 0x80370102 WSL: Windows Subsystem for Linux
Ansible troubleshooting - module failure on Windows-target
Ansible troubleshooting - Unhandled exception while executing module win_user
Thank you
Introduction
This book provides an introduction to the Ansible language.
Ansible is a popular open source IT automation technology for scripting applications in a wide variety of domains.
It is free, portable, powerful, and remarkably easy and fun to use.
This book is a tool to learn the Ansible automation technology with some real-life examples.
Whenever you are new to automation or a profession automation engineer, this book’s goal is to bring you quickly up to speed on the fundamentals of the core Ansible language.
Every successful IT department needs automation nowadays for bare metal servers, virtual machines, cloud providers, containers, and edge computing. Automate your IT journey with Ansible automation technology.
I’m going to teach you example by example how to accomplish the most common System Administrator tasks.
You are going to start with the installation of Ansible in Windows 10 and Windows 11 and use the most command package manager and archives.
Each of the 30+ lessons summarizes a module: from the most important parameter to some live demo of code and real-life usage. Each code is battle proved in the real life. Console interaction and verification are included in every video. A mundane activity like installing software, verifying a system is up-to-date, rebooting a server, installing Google Chrome, copying files from local controller to a remote system, could be automated with some lines of code and these are only some of the long lists included in the course.
There are some Ansible codes usable in all the Windows systems and some specific for Windows Server.
The Ansible troubleshooting lessons teaches you how to read the error message, how to reproduce, and the process of troubleshooting and resolution.
Are you ready to automate your day with Ansible?
Whois Luca Berton
I’m Luca Berton and we’re going to have a lot of fun together.
First of all, let me introduce myself.
I’ve been Ansible Technical Support Engineer of Red Hat, based in the Czech Republic, even if I’m Italian.
I’ve been more than 15 years System Administration, working with infrastructure, either on-premise or on the major cloud providers.
I’m an enthusiast of the Open Source support the community by sharing my knowledge in different events of public access.
I’m also a co-founder of my hometown Linux Users Group, visited by Richard Stallman, the founder of the Free Software Movement.
I consider myself a lazy person so I always try new ways to automate the repetitive task of my work.
After years of Perl, Bash, and python scripting I landed in Ansible technology. I took the certification and worked for more than a year with the Ansible Engineer Team.
I consider Ansible the best infrastructure automation technology nowadays, it’s human-readable, the learning curve is accessible, and very requested by the recruiters in the market.
This ultimate guide contains all of the obvious and not-so-obvious solutions using Ansible automation.
In every lesson of this course, I’m going to share with you one specific use case, the possible solution, the code, the execution, and the verification of the target system.
All these solutions are battle-tested and used by me in my everyday automation.
You could easily jump between lessons and review again all the times that you need.
Awards & Recognition
2022
Ansible Anwendertreffen - From Zero to Hero: How to build the Ansible Pilot Community - by Luca Berton (Red Hat CZ) 15:15 - 16:00 15 Feb 2022
Red Hat Ansible Playbook included in RHSB-2021-009 Log4Shell - Remote Code Execution - log4j (CVE-2021-44228) 12 Jan 2022
AWS Tip Set sysctl kernel parameters — Ansible module sysctl 12 Jan 2022
The Ansible Bullhorn #41 - A Newsletter for the Ansible Developer Community 7 Jan 2022
2021
The Ansible Bullhorn #34 - A Newsletter for the Ansible Developer Community 17 Sep 2021
The course is going to keep track of the evolution of the Ansible technology adding more content whenever is needed.
Are you ready to have fun?
Ansible For Beginners With Examples
In this chapter you’re going to discover the Ansible Basics, Architecture and Terminology.
What is Ansible
In this chapter, I’ll explain to you what is Ansible and why it is so powerful for your IT department.
Ansible
Infrastructure Automation tool
Open Source infrastructure as code
First of all, let’s begin our adventure with the fabulous Open Source technology named Ansible. It is classified as an Infrastructure Automation tool, so you could automate your System Administrator tasks very easily. Infrastructure as code is the process of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools. Ansible follows the DevOps principles. With Ansible you could deploy your infrastructure as code on-premise and on the most well-known public cloud provider.
Ansible three Use Cases
Provision
Config management
Application deployment
The three main use cases of Ansible are provision, configuration management, and app deployment. But after touching the technology I’m sure you could invent some more ways to use it!
Provisioning
The process of setting up the IT infrastructure
Let’s start talking about provisioning: all the System Administrator know how important is to manage a uniform fleet of machines. Some people still rely on software to create workstation images. But there is a drawback, with imaging technology you’re only taking a snapshot in time of the machine. So every time you need to reinstall software because of the modern key activation systems or update manually to the latest security patches. Ansible is very powerful to automate this process being able to create a more smooth process.
Configuration management
The process for maintaining systems and software in a desired and consistent state
The second key use case is configuration management
: maintain up-to-date and in a consistent way all your fleet, coordinating rolling updates and scheduling downtime. With Ansible you could verify the status of your managed hosts and take action in a small group of them. A huge variety of modules is available for the most common use cases. Not to mention the common use case to check the compliance of your fleet to some international standard and apply resolution plans.
Application deployment
The process to publish your software between testing, staging and production environment
The third key use case where Ansible is useful is Application deployment. It could automate the continuous integration / continuous delivery workflow pipeline of your web application for example. Your DevOps team will be delighted!.
Ansible in DevOps
Ansible is used to apply the DevOps principles in worldwide organizations. Let me quickly summarize.
DevOps is a set of practices that combines software development (Dev) and IT operations (Ops). As DevOps is intended to be a cross-functional mode of working, those who practice the methodology use different sets of tools referred to as toolchains
rather than a single one. These toolchains are expected to fit into one or more of the following categories, reflective of key aspects of the development and delivery process. The seven categories:
Code: code development and review, source code management tools, code merging.
Build: continuous integration tools, build status.
Test: continuous testing tools that provide quick and timely feedback on business risks.