Monday 28 August 2023

Automate Linux SysAdmin tasks with Ansible in 95+ examples - part 2


Ansible is a powerful open-source automation tool that allows you to manage and configure your infrastructure as code. Whether you're a beginner looking to install Ansible or an experienced user diving into advanced playbooks, this comprehensive guide has you covered. We'll walk you through various aspects of Ansible, from basic installations on different Linux distributions to executing complex automation tasks.



1. How to Install Ansible in Ubuntu 22.04 LTS

$ sudo apt update
$ sudo apt install ansible

Once installed, you can verify the installation:

$ ansible --version

Now, you're ready to use Ansible for automation tasks on your Ubuntu 22.04 system.

2. Ansible Ad-Hoc Commands: 

Example: Using the Ping Module and Retrieving Ansible Facts

$ ansible all -m ping

$ ansible all -m command -a "hostname"

$ ansible all -m setup

using the "ping" module, we executing commands, and retrieving Ansible facts from target node
Read more »

Labels: , ,

Saturday 31 December 2022

Automate Linux SysAdmin tasks with Ansible in 95+ examples - part 1



1. Decrypting an Ansible Vault

You have an Ansible Vault-encrypted file and need to decrypt it to access the secrets.

ansible-vault decrypt secret_file.yml

Ansible will prompt you for the Vault password used to encrypt the file.You can now access the decrypted data in secret_file.yml.

2.Using Ansible Vault in Ansible Playbooks

---
- name: Example Playbook
  hosts: localhost
  vars:
    sensitive_data: !vault |
      $ANSIBLE_VAULT;1.1;AES256
      66366232396135343865393765653837646562306361623863343535333563373362393865393338

You can create this encrypted variable using ansible-vault encrypt_string.

3.Checking Out Git Repositories via HTTPS with Ansible

You need to automate the process of checking out a Git repository hosted on HTTPS using Ansible.

Create a Playbook to Clone the Git Repository
Read more »

Labels: , ,

Sunday 29 March 2020

Linux User Management - Granting/Revoking sudo access

we will learn how to manage user accounts and grant or revoke sudo access on a Linux system. We will be using Ubuntu as our operating system for this project.

Requirements:

    • Ubuntu installed on a machine

    • Sudo access

    • Basic understanding of Linux commands

Read more »

Labels: , , , ,

Monday 2 March 2020

Linux User Management - Locking/Unlocking user accounts

we will cover the topic of locking and unlocking user accounts in Linux. Locking a user account prevents the user from logging in, while unlocking it allows the user to log in again. This can be useful in situations where a user account has been compromised or is no longer needed.

We will provide code examples for locking and unlocking user accounts, and also discuss how to set up a testing environment on Ubuntu and test the code examples provided.

Read more »

Labels: , ,

Saturday 30 March 2019

How to monitor user and group activity in Linux

Comprehensive explanation of how to monitor user and group activity in Linux using the tools and utilities mentioned Below:

ps command:

The "ps" command (short for process status) displays a snapshot of running processes on a Linux system. To view the processes running under a specific user, you can use the "-u" option followed by the username. For example, to see all the processes running under the user "john," you can use the following command:

ps -u john


This will display a list of all the processes running under the user "john" along with their process ID (PID), CPU usage, memory usage, and other relevant information.

Read more »

Labels: , ,