This document provides an overview and introduction to using Ansible for automation and configuration management. It discusses key Ansible concepts like playbooks, roles, modules, variables and facts. The document is split into multiple sections covering basics like setting up Ansible, using ad-hoc commands and playbooks, and more advanced topics such as roles, templates, and the Ansible Galaxy utility.
Implementing DevOps Using Vagrant with Ansible
Understanding DevOps
Provisioning Vagrant Machines
Integrating Vagrant with Ansible
Creating a Vagrant Development Environment
Completing the Vagrant DevOps Environment
Introduction
Definitions
Why ansible
Understanding YAML
YAML Data presentation syntax
Basics getting started
Setting up ansible
Managing configuration and Inventory
Ad-hoc commands
Working with modules
Understanding playbooks
Variables, includes, imports and facts
Understanding Jinja2 templates
Working with roles
Understanding role structure
Creating roles
Deploying roles with ansible galaxy
Using the ansible galaxy CLI utility
This presentation is an introduction to Ansible, an IT automation tool which can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
'Ansible Roles done right' is a talk about "Applying TDD while writing roles. Automatic tests powered by Continuous Integration + containers. Quick demo of the new ansible-container." Funny title: "When your applications don't have tests, at least your infrastructure does..."
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017Jumping Bean
An overview of the LPI-OT DevOps Tools Engineer certification's Ansible objectives. The slides cover the concepts and components of Ansible and demonstrate the basic principles of any infrastructure as code management tool such as idempotence and repeatability.
Implementing DevOps Using Vagrant with Ansible
Understanding DevOps
Provisioning Vagrant Machines
Integrating Vagrant with Ansible
Creating a Vagrant Development Environment
Completing the Vagrant DevOps Environment
Introduction
Definitions
Why ansible
Understanding YAML
YAML Data presentation syntax
Basics getting started
Setting up ansible
Managing configuration and Inventory
Ad-hoc commands
Working with modules
Understanding playbooks
Variables, includes, imports and facts
Understanding Jinja2 templates
Working with roles
Understanding role structure
Creating roles
Deploying roles with ansible galaxy
Using the ansible galaxy CLI utility
This presentation is an introduction to Ansible, an IT automation tool which can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
'Ansible Roles done right' is a talk about "Applying TDD while writing roles. Automatic tests powered by Continuous Integration + containers. Quick demo of the new ansible-container." Funny title: "When your applications don't have tests, at least your infrastructure does..."
DevOpsDaysCPT Ansible Infrastrucutre as Code 2017Jumping Bean
An overview of the LPI-OT DevOps Tools Engineer certification's Ansible objectives. The slides cover the concepts and components of Ansible and demonstrate the basic principles of any infrastructure as code management tool such as idempotence and repeatability.
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
Ansible is a radically simple IT automation engine. This is new and great configuration management system (like Chef, Puppet) that has been created in 2012 year. Also Ansible is pretty simple and flexible system, that helps you in managing your servers and execute Ad-hoc commands.
During this session I will explain how to start using Ansible in infrastructure orchestration and what are pros and cons of this system. Also I will explain you our experience in deployments, provisioning and other aspects.
Yesterday I gave presentation on Ansible and it was successful . It give basic understanding of playbook and an example implementation of jboss application from scratch
Introduction to Ansible - Peter HalliganCorkOpenTech
Cork Open Technology Presentation, 20th November 2018.
Ansible is an open source automation language. It’s also a deployment and orchestration tool. We will look at some of the core concepts and use cases, rolling updates, version controlled deployment and Infrastructure as code.
Presentation from Henry Gallo and Steve Paelet at DevOps NYC Meetup on Thursday, February 20, 2020
Understanding the Relationship: Ansible & Terraform
https://www.meetup.com/DevOps-NYC/events/267780085/
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
Ansible is a radically simple IT automation engine. This is new and great configuration management system (like Chef, Puppet) that has been created in 2012 year. Also Ansible is pretty simple and flexible system, that helps you in managing your servers and execute Ad-hoc commands.
During this session I will explain how to start using Ansible in infrastructure orchestration and what are pros and cons of this system. Also I will explain you our experience in deployments, provisioning and other aspects.
Yesterday I gave presentation on Ansible and it was successful . It give basic understanding of playbook and an example implementation of jboss application from scratch
Introduction to Ansible - Peter HalliganCorkOpenTech
Cork Open Technology Presentation, 20th November 2018.
Ansible is an open source automation language. It’s also a deployment and orchestration tool. We will look at some of the core concepts and use cases, rolling updates, version controlled deployment and Infrastructure as code.
Presentation from Henry Gallo and Steve Paelet at DevOps NYC Meetup on Thursday, February 20, 2020
Understanding the Relationship: Ansible & Terraform
https://www.meetup.com/DevOps-NYC/events/267780085/
● Fundamentals
● Key Components
● Best practices
● Spring Boot REST API Deployment
● CI with Ansible
● Ansible for AWS
● Provisioning a Docker Host
● Docker&Ansible
https://github.com/maaydin/ansible-tutorial
Introduction to Ansible - (dev ops for people who hate devops)Jude A. Goonawardena
This presentation covers the fundamentals of Ansible and it is useful for the people who are seeking information to start using Ansible, what it is capable of and how to use it right. I purposely made syntax errors in certain slides to demonstrate how to fix such errors and giving the idea of the importance to write syntax right. If you have any questions please don't hesitate to contact me over my mail address judeashan@gmail.com. All the best!!
Presented by Michael Lynn, Senior Solutions Architect, MongoDB
Deploying databases, applications and infrastructure can be a difficult task. Once the applications and databases have been deployed, the tasks associated with managing, monitoring, backing up can be even more complex.
Ansible provides developers the ability to deploy, provision and configure your application and database infrastructure for swift delivery to any hosting platform: physical, virtual, cloud or on-premise.
Ops Manager, simply put, is the best way to run MongoDB in your environment. It provides the ability to deploy, monitor, manage, and backup your MongoDB databases.
In this presentation, you will learn how to automate deployment of a MongoDB Ops Manager environment from the ground up, and deploy it to datacenters around the world with a few simple commands using Ansible.
Learning Objectives:
- Attendees will learn about Ansible, and how playbooks and tasks work
- Attendees will learn how to create simple playbooks to deploy MongoDB servers for management via MongoDB Ops Manager
- Attendees will learn how to monitor, manage and backup their MongoDB infrastructure using Ops Manager from MongoDB
PLNOG14: Automation at Brainly - Paweł RozlachPROIDEA
Paweł Rozlach - Brainly
Language: English
Ansible is an emerging automation system, which in comparison to Puppet is much simpler and easier to use and at the same time - more flexible and equally powerfull. We will try to describe how it can be used basing on our expirience gathered during last year.
Register to the next PLNOG edition today: krakow.plnog.pl
Discover more about Ansible! Ansible Tower and Ansible Containers:)
The slides which I used to give a talk about Ansible at DevOps North East. The slides have been modified to make it easier to understand in case you have missed the talk :)
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
2. Table of contents
( part A - Basics )
1. Introduction
a. Definitions
b. Why ansible
c. Understanding YAML
■ YAML Data presentation syntax
2. Basics getting started
a. Setting up ansible
b. Managing configuration and Inventory
c. Ad-hoc commands
d. Working with modules
e. Understanding playbooks
f. Variables, includes, imports and facts
g. Understanding Jinja2 templates
3. Working with roles
a. Understanding role structure
b. Creating roles
c. Deploying roles with ansible galaxy
d. Using the ansible galaxy CLI utility
Iman Darabi
https://www.linkedin.com/in/imandarabi/
3. Table of contents
( part B - Advanced )
1. Managing task control
a. Using with_items
b. Using Nested Loops
c. Using the when statement
d. Registering variables
e. Working with handlers
f. Working with tags
g. Dealing with errors
h. Using ansible blocks
2. Ansible vault
a. Understanding ansible Vault
b. Working with encrypted files
c. Executing with ansible vault
3. Optimizing ansible
a. Selecting hosts with host patterns
b. Configuring delegation
c. Delegation outside the inventory
d. Configuring parallelism
4. Troubleshooting ansible
a. Understanding ansible logging
b. Troubleshooting playbooks
c. Troubleshooting managed hosts
Iman Darabi
https://www.linkedin.com/in/imandarabi/
5. 1.a) Definitions
● Simple automation language that can perfectly describe an IT application infrastructure in
ansible playbooks
● Open-source software provisioning, configuration management, and
application-deployment tool (wikipedia).
● Initial release: February 20, 2012
● Repository: github.com/ansible/ansible
● Ansible, an open source community project sponsored by Red Hat,
● Other configuration management tools:
○ Puppet
○ Chef
○ Juju
○ Salt …
6. 1.b) Why ansible
● Minimal learning required
○ Human readable automation
○ No special coding skills needed
○ Tasks executed in order
● Only OpenSSH and Python are required on the managed nodes
● Agent-less ( no exploit or update )
● Powerful
○ App deployment
○ Configuration management
○ Workflow orchestration
○
9. ● YAML is a human-readable data serialization standard that can be used in conjunction
with all programming languages and is often used to write configuration files.
● YAML has no executable commands. It is simply a data-representation language.
● It is commonly used for configuration files and in applications where data is being stored
or transmitted.
● YAML files should end in .yaml/.yml
● YAML is case sensitive.
● YAML does not allow the use of tabs. Spaces are used instead as tabs are not universally
supported.
● We use YAML because it is easier for humans to read and write than other common data
formats like XML or JSON
13. Data type - key value pair
● Key value pairs are defined using a
colon ( : ) and a space ( )
---
Fruit: Apple
Vegetable: Carrot
Liquid: Water
Meet: Chiken
14. Data type - Array / Lists
● Dash “-” indicates elements of lists
# Block Format
Fruites:
- Orange
- Apple
# Inline Format
Fruits: [ Orange, Apple ]
15. Data type - Dictionary / Map
● There must be equal number of blank
space ( ) for each of properties
Banana:
Calories: 105
Fat: 0.4
Grapes:
Calories: 62
Fat: 0.3
16. Data type - Strings
data: |
Each of these
Newlines
Will be broken up
data: >
This text is
wrapped and will
be formed into
a single paragraph
20. Setting up controller and remote hosts
1. Install Ansible software
a. Only the control node needs ansible
i. # apt install ansible
b. Managed hosts need Python and SSH
2. Create a non-root user and perform all tasks as this user
3. Set up SSH for communications
4. Configure sudo
a. user ALL=(ALL) NOPASSWD: ALL
22. configuration file
● ansible.cfg defines ansible configurations
● It is common work to work with project directories that contain these files
● Search order of changes in configuration files are as follow:
○ ANSIBLE_CONFIG (environment variable if set)
○ ansible.cfg (in the current directory)
○ ~/.ansible.cfg (in the home directory)
○ /etc/ansible/ansible.cfg
● Create Base directory and add ansible.cfg & inventory files as follows
● Change directory to the Base dir and run the following command to check it all works:
○ $ ansible all --list-hosts
23. Inventory file
● Inventory contains a list of hostnames or IP addresses
● Dynamic inventory is discussed later
● Default inventory file: /etc/ansible/hosts
●
24. Inventory file sample
INI format
mail.example.com
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
YAML format
all:
hosts:
mail.example.com:
children:
webservers:
hosts:
foo.example.com:
bar.example.com:
dbservers:
hosts:
one.example.com:
two.example.com:
three.example.com:
27. Ad-hoc Commands Summarized
● Ansible modules can be called using the ansible command
● Use ansible-doc -l for a list of modules, and ansible-doc modulename for information
● Specify which module to use, using -m
● The command module is default, and does not have to be specified
○ ansible all ping
● about module options
○ Ansible <category_inventory> -m <module_name> -a <module_arg>
○ Ansible all -m command -a id
○ Ansible all -m shell -a env
29. modules
● Modules are reusable, standalone scripts that can be used by the Ansible API,
the ansible command, or the ansible-playbook command.
● Modules provide a defined interface, accepting arguments and returning
information to Ansible by printing a JSON string to stdout before exiting.
30. Module usage
Ad-hoc command
# ansible all -m apt -a "name=htop
state=present"
Playbook
hosts: all
tasks:
- name: install htop application
apt:
name: htop
state: present
32. playbooks
● A list of instruction describing the steps to bring your server to a certain
configuration stat
● Playbook - A single YAML file
○ Play - Defines a set of activities (task) to be run on hosts
■ Task - An action to be performed on the host
● Execute a command
● Run a script
● Install a package
● Shutdown/Restart
33. Playbook format
# simple Ansible Playbook.yml
---
-
name: Play 1
hosts: localhost
tasks:
- name: Execute command ‘date’
command: date
- name: Execute script on server
script: test_script.sh
-
name: Play 2
hosts: localhost
tasks:
- name: Install web service
yum:
name: httpd
state: present
34. Playbook keywords
# simple Ansible Playbook.yml
---
-
name: Play 1
hosts: localhost
tasks:
- name: Execute command ‘date’
command: date
- name: Execute script on server
script: test_script.sh
-
name: Play 2
hosts: localhost
tasks:
- name: Install web service
yum:
name: httpd
state: present
35. Playbook keywords
● name: Identifier. Can be used for documentation, in or tasks/handlers.
● hosts: A list of groups, hosts or host pattern that translates into a list of hosts that are
the play’s target.
● tasks: Main list of tasks to execute in the play, they run after roles and before post_tasks.
● vars, when, tags, until, async, become, delegate_to and …
○ https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html
39. Understanding Variables and Inclusions
● Variables are what makes ansible flexible: set a variable locally to have it behave
differently on different managed hosts
○ Variables can be set through the inventory file, at the top of a playbook or using inclusions
● Ansible facts can be used like variables as well:
● Inclusions allow you to make ansible playbooks more modular
○ Instead of writing one big playbook, you can work with several small playbooks, where each
playbook is used to focus on a specific set of tasks.
40. Including and Importing
include: install-packages.yml import_tasks: install-packages.yml
● All import* statements are pre-processed at the time playbooks are parsed.
● All include* statements are processed as they are encountered during the
execution of the playbook.
41. Facts
● As we’ve already seen, when Ansible runs a playbook, before the first task runs, this
happens:
● GATHERING FACTS **************************************************
● ok: [servername]
● When Ansible gather facts, it connects to the host and queries the host for all kind of
details about the host: CPU arch, operating system, IP address, memory, disk info …
● This information is stored in variables that are called facts, and they behave just like any
other variable does.
42. Facts - ad-hoc samples
● Display facts from all hosts and store them indexed by I(hostname) at C(/tmp/facts).
○ # ansible all -m setup --tree /tmp/facts
● Display only facts regarding memory found by ansible on all hosts and output them.
○ # ansible all -m setup -a 'filter=ansible_*_mb'
● Display only facts about certain interfaces.
○ # ansible all -m setup -a 'filter=ansible_eth[0-2]'
43. Special variables
● These variables cannot be set directly by the user; Ansible will always override them to
reflect internal state.
● Inventory_hostname
○ The inventory name for the ‘current’ host being iterated over in the play
● Inventory_hostname_short
○ The short version of inventory_hostname
● ansible_distribution
○ Os distribution like “Debian” or “Ubuntu” or “CentOS”
● Reference:
○ https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
45. Jinja2 Templates
● Jinja2 templates are Python-based templates that are used to put host-specific data on
hosts, using generic YAML and Jinja2 files
● Jinja2 templates are used to modify Yaml files before they are sent to the managed host
● Jinja2 can also be used to reference variables in playbooks
● As advanced usage, Jinja2 loops and conditionals can be used in templates to generate
very specific code
● The host-specific data is generated through variables or facts
47. 3.a) Understanding role structure
● Idea: if you design in a structured way, everybody knows where to find what !
● Ansible roles provide uniform ways to load tasks, handlers, and variables from external
files
● A role typically corresponds to the type of service that is offered (web, database, etc.)
● The purpose is to keep the size of playbooks manageable
● Roles use a specific directory structure, with locations for default, handlers, tasks,
templates, and variables
48. Role directory structure contents
● defaults: contains a main.yml with default values for variables
● files: static files that are referenced by role tasks
● handlers: contains a main.yml with handler definitions
● meta: contains a main.yaml with informations about the role, including author,
license, platforms, and dependencies
● tasks: has a main.yml with task definitions
● vars: has a main.yml file with role variable definitions
49. Understanding role variables
● Role variables are defined in vars/main.yml
● These variables have a high priority and cannot be overridden by inventory
variables
● Default variables can be defined in defaults/main.yml and have the lowest
precedence
● Use default variables only if you intend to have the variable overridden somewhere
else
○ Overriding variables is common as roles are used as templates, where specific
variables may be overridden in specific playbooks
50. Using Roles
● Roles are easily used from playbooks:
---
- hosts: node2.ansible.local
roles:
- role1
- role2
51. 3.b) Creating roles
● Creating roles involves the following steps
○ Create the role structure
○ Define the role content
○ Use the role in a playbook
● Use the ansible-galaxy init <role_name> command to automate creating the role
directory structure
●
52. 3.c) Deploying roles with ansible galaxy
● Ansible Galaxy ( http://galaxy.ansible.com ) is the community resource for getting and
publishing roles
● Many roles that are ready to use are offered for download
● Roles that are still in development can be followed by watchers
● Use ansible-galaxy command to install roles from galaxy.ansible.com
○ Ansible-galaxy install <rolename>
54. 3.d) Using the ansible galaxy CLI utility
● # Ansible-galaxy search
○ Search for roles
● Use options --author, --platforms and --galaxy-tags to narrow down search results
● # ansible-galaxy search “install mariadb” --platforms el
● # ansible-galaxy info
○ Provides information about roles
○ # ansible galaxy info f500.mariadb55
● # ansible-galaxy install <rolename>
○ Download a role and install it on the control node in ~/.ansible/roles
55. End of part A
Iman darabi
https://www.linkedin.com/in/imandarabi/