Professional Documents
Culture Documents
Ansible Rhel 90
Ansible Rhel 90
Ansible Rhel 90
2
Introduction
Topics Covered:
3
Red Hat Ansible Platform technical deck
4
Red Hat Ansible Platform technical deck
5
Why the Red Hat Ansible Automation Platform?
6
Why the Red Hat Ansible Automation Platform?
Do this...
Orchestrate Manage configurations Deploy applications Provision / deprovision Deliver continuously Secure and comply
On these...
7
Red Hat Ansible Platform technical deck
Consistent governance
Cloud
Edge Datacenter
Line of business
8
What makes a platform?
Fueled by an
open source community
9
Automation and IT modernization
Source:
Gardner, Chris, Glenn O'Donnell, Robert Perdonii, and Diane Lynch. "The Forrester Wave™: Infrastructure Automation Platforms, Q3 2020." Forrester, 10 Aug. 2020.
DISCLAIMER: The Forrester Wave™ is copyrighted by Forrester Research, Inc. Forrester and Forrester Wave™ are trademarks of Forrester Research, Inc. The Forrester Wave™ is a graphical representation of
Forrester’s call on a market and is plotted using a detailed spreadsheet with exposed scores, weightings, and comments. Forrester does not endorse any vendor, product, or service depicted in the Forrester
Ansible automates technologies you use
Time to automate is measured in minutes
12
The lab environment today
● Drink our own champagne. Workbench Topology
Provisioned by, configured by, and
managed by Red Hat Ansible
Amazon VPC router
Automation Platform.
https://github.com/ansible/workshops
15
Red Hat Ansible Platform technical deck: Create
Create
The automation lifecycle
Discover
Automation hub
16
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: install and start apache
hosts: web
become: yes
tasks:
- name: httpd package is present
yum:
name: httpd
state: latest
17
Red Hat Ansible Platform technical deck: Create
18
Red Hat Ansible Platform technical deck: Create
Ansible plays
What am I automating?
19
Red Hat Ansible Platform technical deck: Create
Ansible modules
The “tools in the toolkit”
Language
Usually Python, or Powershell for Windows
setups. But can be of any language.
20
Red Hat Ansible Platform technical deck: Create
Ansible plugins
The “extra bits”
Example become plugin:
---
What are they? - name: install and start apache
hosts: web
Plugins are pieces of code that augment become: yes
Ansible’s core functionality. Ansible uses a
Example filter plugins:
plugin architecture to enable a rich, flexible,
{{ some_variable | to_nice_json }}
and expandable feature set. {{ some_variable | to_nice_yaml }}
21
Red Hat Ansible Platform technical deck: Create
Ansible Inventory
The systems that a playbook runs against
[web]
webserver1.example.com
webserver2.example.com
What are they?
[db]
List of systems in your infrastructure that
dbserver1.example.com
automation is executed against
[switches]
leaf01.internal.com
leaf02.internal.com
22
Red Hat Ansible Platform technical deck: Create
Ansible roles
Reusable automation actions
---
What are they? - name: install and start apache
hosts: web
Group your tasks and variables of your
roles:
automation in a reusable structure. Write roles - common
once, and share them with others who have - webservers
similar challenges in front of them.
23
Red Hat Ansible Platform technical deck: Create
Collections
Simplified and consistent content delivery
24
Red Hat Ansible Platform technical deck: Create
Collections
deploy-nginx.yml
nginx_core ---
├── MANIFEST.json - name: Install NGINX Plus
├── playbooks hosts: all
│ ├── deploy-nginx.yml tasks:
│ └── ... - name: Install NGINX
├── plugins include_role:
├── README.md name: nginxinc.nginx
└── roles vars:
├── nginx nginx_type: plus
│ ├── defaults
│ ├── files - name: Install NGINX App Protect
│ │ └── … include_role:
│ ├── tasks name: nginxinc.nginx_app_protect
│ └── templates vars:
│ └── ... nginx_app_protect_setup_license: false
├── nginx_app_protect nginx_app_protect_remove_license: false
└── nginx_config nginx_app_protect_install_signatures: false
25
Why the Red Hat Ansible Automation Platform?
90+
Infrastructure Cloud Network Security
certified platforms
26
How Ansible Automation Works
Module code is
executed locally on the
Network Devices /
control node API Endpoints
Ansible Automation Platform
Local Execution
Linux / Windows
Module code is copied
to the managed node,
Hosts
Ansible Automation Platform
executed, then
removed Remote Execution
Verify Lab Access
28
Lab Time
Complete exercise 1-setup now in your lab environment
Exercise 2
Topics Covered:
● Ansible inventories
30
Inventory
31
Red Hat Ansible Platform technical deck: Create
Ansible Inventory
[myservers]
The Basics 10.42.0.2
10.42.0.6
An example of a static Ansible inventory 10.42.0.7
10.42.0.8
including systems with IP addresses as
10.42.0.100
well as fully qualified domain name host.example.com
(FQDN)
32
Ansible Inventory - The Basics
[app1srv]
appserver01 ansible_host=10.42.0.2
appserver02 ansible_host=10.42.0.3
[web]
node-[1:30] ansible_host=10.42.0.[31:60]
[web:vars]
apache_listen_port=8080
apache_root_path=/var/www/mywebdocs/
[all:vars]
ansible_user=kev
ansible_ssh_private_key_file=/home/kev/.ssh/id_rsa
33
Ansible Inventory - Variables
[app1srv]
appserver01 ansible_host=10.42.0.2
appserver02 ansible_host=10.42.0.3
[web]
node-[1:30] ansible_host=10.42.0.[31:60]
[web:vars]
apache_listen_port=8080
apache_root_path=/var/www/mywebdocs/
[all:vars]
ansible_user=ender
ansible_ssh_private_key_file=/home/ender/.ssh/id_rsa
34
Ansible Inventory - Groups
[nashville]
bnaapp01
bnaapp02
[atlanta]
atlapp03
atlapp04
[south:children]
atlanta
nashville
hsvapp05
35
Red Hat Ansible Platform technical deck: Create
36
Red Hat Ansible Platform technical deck: Create
> ANSIBLE.BUILTIN.USER
Aside from listing a full list of all the modules, you
(/usr/lib/python3.8/site-packages/ansible/m
can use ansible-navigator to provide details about odules/user.py)
a specific module.
Manage user accounts and user attributes.
In this example, we are getting information about For Windows targets, use the
the user module. [ansible.windows.win_user] module
instead.
37
Lab Time
Complete exercise 2-thebasics now in your lab environment
Exercise 3
Topics Covered:
● Playbooks basics
● Running a playbook
40
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: install and start apache
hosts: web
become: yes
tasks:
- name: httpd package is present
yum:
name: httpd
41
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: install and start apache
hosts: web
become: yes
tasks:
- name: httpd package is present
A task
yum:
name: httpd
state: latest
42
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: install and start apache
hosts: web
become: yes
tasks:
- name: httpd package is present
A module yum:
name: httpd
state: latest
43
Ansible Colors
Running Playbooks
The most important colors of Ansible
44
Red Hat Ansible Platform technical deck: Operate
A playbook run
Where it all starts
45
Red Hat Ansible Platform technical deck: Create
What is ansible-navigator?
ansible-navigator command line utility and $ ansible-navigator run playbook.yml
text-based user interface (TUI) for running
and developing Ansible automation content.
46
Red Hat Ansible Platform technical deck: Create
ansible-navigator
Bye ansible-playbook, Hello ansible-navigator
47
ansible-navigator
Mapping to previous Ansible commands
51
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: variable playbook test
hosts: localhost
vars:
var_one: awesome
var_two: ansible is
var_three: "{{ var_two }} {{ var_one }}"
tasks:
- name: print out var_three
debug:
msg: "{{ var_three }}"
52
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: variable playbook test
hosts: localhost
vars:
var_one: awesome
var_two: ansible is
var_three: "{{ var_two }} {{ var_one }}"
tasks:
- name: print out var_three
debug:
msg: "{{ var_three }}"
ansible is awesome
53
Ansible Facts
tasks:
▸ Just like variables, really... - name: Collect all facts of host
setup:
▸ … but: coming from the host itself! gather_subset:
▸ Check them out with the setup module - 'all'
54
Red Hat Ansible Platform technical deck: Create
Ansible playbooks
---
- name: facts playbook
hosts: localhost
tasks:
- name: Collect all facts of host
setup:
gather_subset:
- ‘all’
55
Red Hat Ansible Platform technical deck: Create
PLAY NAME OK CHANGED UNREACHABLE FAILED SKIPPED IGNORED IN PROGRESS TASK COUNT PROGRESS
0│facts playbook 2 0 0 0 0 0 0 2 COMPLETE
56
Ansible Inventory - Managing Variables In Files
$ tree ansible-files/
├── deploy_index_html.yml
├── files
│ ├── dev_web.html
│ └── prod_web.html
├── group_vars
│ └── web.yml
└── host_vars
└── node2.yml
57
Ansible Inventory - Managing Variables In Files
├── $ cat group_vars/web.yml
---
deploy_index_html.yml stage: dev
├── files
│ ├── dev_web.html
│ └── prod_web.html $ cat host_vars/node2.yml
---
├── group_vars stage: prod
│ └── web.yml
└── host_vars
- name: copy web.html
└── node2.yml copy:
src: "{{ stage }}_web.html"
dest: /var/www/html/index.html
58
Lab Time
Complete exercise 4-variables now in your lab environment
Exercise 5
Topics Covered:
● Surveys
60
Surveys
Controller surveys allow you to configure
how a job runs via a series of questions,
making it simple to customize your jobs in
a user-friendly way.
66
Automation Hub and Ansible Galaxy
Ansible Content
Roles & Collections
Examples
---
- name: example system roles playbook
hosts: web
tasks:
69
Lab Time
Complete exercise 6-system-roles now in your lab environment
Red Hat Insights for Red Hat Ansible Automation Platform
Where to go next
Learn more
▸ Workshops
▸ Documents
▸ Youtube
▸ Twitter
Get started
▸ Evals
▸ cloud.redhat.com
Get serious
▸ Red Hat Automation Adoption Journey
▸ Red Hat Training
▸ Red Hat Consulting
94
linkedin.com/company/red-hat
facebook.com/ansibleautomation
twitter.com/ansible
github.com/ansible
95