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: null
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 - https://www.patreon.com/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) - https://www.youtube.com/watch?v=n0a8HotVvdg
How to Install AlmaLinux 9.0 - https://www.youtube.com/watch?v=eGvDIAX-iek
Installing Ansible - https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
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!!!
9 Comments