This is How You Should Install and Configure Ansible on Linux!!!

Published: 04 November 2022
on channel: The Lazy SysAdmin
8,490
172

In this video, you will learn how I install and configure Ansible controller node on AlmaLinux 9.

Join this channel to get access to perks: https://www.youtube.com/@lazysysad/join

You will learn how I install Ansible using pip!

PLEASE SUBSCRIBE :)
PLEASE HIT LIKE IF IT HELPED :)

You will also learn how I wrote the Ansible scripts to update my web and database servers with a one-liner command.

Please note that there are many ways you can install and configure Ansible. But this is the way I do it.

GIVE SUPPORT -   / lazysysad  
BUY ME A COFFEE - https://www.buymeacoffee.com/lazysysad
PAYPAL - https://paypal.me/lazysysad

LINKS:
Install Ansible Semaphore in AlmaLinux 9 (UI for Ansible - Open Source Ansible Tower Alternative) -    • Install Ansible Semaphore in AlmaLinu...  
How to Install AlmaLinux 9.0 -    • How to Install AlmaLinux 9.0 Minimal ...  
Installing Ansible - https://docs.ansible.com/ansible/late...

Commands:
sudo dnf -y update
sudo reboot
sudo su -
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
python3 -m pip install ansible
python3 -m pip show ansible
exit
ssh-keygen
ssh-copy-id -i ~/.ssh/ansible web1.lazy.test
ssh-copy-id -i ~/.ssh/ansible db1.lazy.test

mkdir ansible
cd ansible

mkdir -p \
inventory/prod/{group_vars,host_vars} \
inventory/stage/{group_vars,host_vars} \
inventory/test/{group_vars,host_vars} \
roles \
playbooks

vi inventory/test/hosts
[webservers]
web1.lazy.test

[dbservers]
db1.lazy.test

ansible-config init --disabled -t all

vi ansible.cfg
roles_path=~/ansible/roles
interpreter_python=auto_silent
private_key_file=~/.ssh/ansible
private_key_file=~/.ssh/ansible
host_key_checking = False

ansible -i inventory/test/hosts -m ping all
ansible-galaxy init update_system

vi update_system/tasks/main.yml
- name: Update all packages
include_tasks: '{{ item }}'
with_first_found:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'

vi update_system/tasks/RedHat.yml
---
- name: Upgrade all packages (RedHat based systems)
ansible.builtin.dnf:
name: '*'
state: latest
update_cache: yes
update_only: yes

vi update_system/tasks/Ubuntu.yml
---
- name: Upgrade all packages (Ubuntu based systems)
ansible.builtin.apt:
name: "*"
state: latest
update_cache: yes
cache_valid_time: 3600

cd ../playbooks
mkdir updates
vi updates/update_system.yml
---
- hosts: all
gather_facts: yes
become: yes
become_user: root
tasks:
- ansible.builtin.import_role:
name: update_system

sudo dnf -y install tree
tree

cd ..
ansible-playbook -i inventory/test/hosts playbooks/updates/update_system.yml -K

Chapters:
00:00 Intro
00:25 Update AlmaLinux 9
01:06 Ansible Installation
02:30 Generate SSH Key Pair
02:53 Ansible Directory Structure
03:33 Ansible Inventory
03:49 Ansible Configuration
05:30 Create Ansible Role
06:30 Create Ansible Playbook
07:13 Ansible Directory Structure
07:37 Run the Ansible Playbook
08:03 Outro

Drop me your feedback and comments below.

That's all for now.

If this video helped you in any way, please like share and subscribe!

Thank you!!!


Watch video This is How You Should Install and Configure Ansible on Linux!!! online without registration, duration hours minute second in high quality. This video was added by user The Lazy SysAdmin 04 November 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 8,490 once and liked it 172 people.