Skip to content

Instantly share code, notes, and snippets.

View dmccuk's full-sized avatar
🏠
Working from home

Dennis McCarthy dmccuk

🏠
Working from home
View GitHub Profile
let an Ansible role from scratch and do the following things, and then deploy the role.
* Create the role
* Setup the tasks using best practice
* Add templates with ansible facts
* Setup handlers for when things change
* Make the whole thing idempotent and not task run unless it needs to
* Show how variable precedence works for default, vars & group_vars
All the code for this demo is available below. Don't forget to like and subscribe!
Systemd gives us the ability to create services out of almost anything. If you want to run an application and make sure that the application is available after a reboot, consider creating a service to manage that for you.
In this Demo, I’ll cover the following:
• Create a simple bash script to output the date to a log file.
• Setup the basic systemd service unit file.
• Reload systemd to pick up the new service.
• Enable, then start the service.
• Stop and restart the service.
• Test it with a server reboot.

Ansible: Create Local / Custom facts on Windows Servers

This demo follows on from Ansible: How to manage Windows servers using winrm

Subscribe To Me On YouTube: https://bit.ly/lon_sub

Go through that video first to setup your environment.

Please consider Subscribing to support my channel.

If you manage a groups of servers, be they Linux or Windows using Ansible, sometimes you need to get a specific piece of information

Ansible: Run Playbooks From Other Teams

Some companies put the onnus of installing and setting up an application, onto the application teams themselves. This means they can leverage the power of the existing automation to stand up their application and reduce the time it takes to get up and running. They'll need to write the ansible playbooks to cover off all of their application requirements, but once that code exists, it's a simple matter to make small updates and tweaks manage that application going forward.

This demo will cover

  • Set-up a basic playbook to make a few simple updates on a remote server.
  • Create a couple of Ansible roles in a new GitHub repo (pre-perpared).
  • Create the requirements.yml file correctly andin the right place to pull down the new ansible roles from a different

Manage Windows Servers using Ansible

This is a real-time demo of how to set up your windows servers so they can be managed by ansible. I've created a YouTube companion video demo here: https://youtu.be/aPN18jLRkJI

Subscribe To Me On YouTube: https://bit.ly/lon_sub

The following is covered by this demo:

  • Setup a windows 2016 (or 2019/2021) server so ansible can manage it (over HTTPS)
  • Setup my Centos 8 server so it can manage windows servers using winrm

Ansible – Set_facts conditional example

In ansible, like any other programming language, at some point, we’ll want to set a variable for something. This is fairly simple to do when it’s just one value, but if we need to pick that value from the server we run ansible against, it gets a bit trickier.

Subscribe To Me On YouTube: https://bit.ly/lon_sub

Checkout the Youtube Video walkthrough here: https://youtu.be/NUGAQQ7p-Ho

Subscribe to my YouTube channel for more videos like this

For example:

{
"support": "github.com/dmccuk/SponsorMe",
"YouTubeChannel": "youtube.com/c/LondonIAC",
"linkedIn": "linkedin.com/in/dennismccarthyuk/",
"meetup": "meetup.com/londoniac",
"website": "londoniac.co.uk/",
}

In this demo, I'll cover the following tasks:

Subscribe To Me On YouTube: https://bit.ly/lon_sub

  • Start with a newly built Ubuntu 20.04 server
  • Install pre-requisite packages
  • Install Jenkins
  • Install some other helpful packages like ansible, wget, git, etc
  • Install the default plugins
  • Login and setup the Admin user

Cloud shell

Free VM playgroud

Subscribe To Me On YouTube: https://bit.ly/lon_sub

If you're looking for a FREE environment for testing your code against, Have you heard about Google cloud shell??

If you have a gmail account, you get FREE access to you're own VM.

Please click the **Subscribe** button. I really appreciate it!

Ansible: Nested and Dynamic Variables

This is a quick demo to show you how to use nested variables, then override them to make them useful in your playbooks.

Subscribe To Me On YouTube: https://bit.ly/lon_sub

Create a role

The first thing we do is create a new role to put our ansible code:

mkdir roles