Skip to content

Instantly share code, notes, and snippets.

View seomago's full-sized avatar
:octocat:
Playing with AWS cloud

seomago seomago

:octocat:
Playing with AWS cloud
View GitHub Profile
@seomago
seomago / Ansible_Assert.txt
Created January 4, 2022 21:34 — forked from dmccuk/Ansible_Assert.txt
Prove ansible did what is said it did!
-- Ansible testing using Assert
When we run Ansible to manage server configurations, we assume (if there is no red errors) that it worked. But if you are developing ansible modules for your systems, and want to take the DevOps approach and work on CICD pipelines, you need to have some tests in there to prove that what you asked ansible to do has actually worked.
One of the best ways to do this within ansible, is to use the Assert module. It asserts that a given expression is true. When you combine this with the output of a command that’s registered to a variable, there is almost no limit to what you can test.
I’m going to use the TDD (Test driven development) method where we create the tests before we start writing any ansible code to manage our systems. I expect the tests to fail. Then we’ll write ansible to pass the tests. That’s it.
This demo will cover the following:
• Create some tests using the command and assert modules.
#https://github.com/ferhaty/azure-cli-cheatsheet
azure
account
list [options] #List the imported subscriptions
show [options] [subscriptionNameOrId] #Show details about a subscription
set [options] <subscriptionNameOrId> #Set the current subscription
clear [options] #Remove a subscription or environment, or clear all of the stored account and environment info
import [options] <file> #Import a publishsettings file or certificate for your account
download [options] #Launch a browser to download your publishsettings file