Posts

Showing posts with the label DevOps

How to Integrate Ansible with AWS EC2 and Manage Instances Dynamically

If you're working with AWS EC2 and want to automate your infrastructure using Ansible, this guide shows how to set up a dynamic inventory system. This means Ansible will automatically detect your EC2 instances based on tags—no need to maintain static inventory files! Step 1: Install Required Dependencies On your Ansible control node, make sure you have Python and pip installed. Then install the AWS SDK for Python (boto3), which is required for Ansible to communicate with AWS APIs. sudo yum install python3 -y pip3 install boto3 Also, configure AWS CLI with appropriate credentials: aws configure Why this matters: Boto3 and AWS CLI let Ansible fetch details about your EC2 infrastructure dynamically, based on filters like tags and regions. Step 2: Create the Dynamic Inventory Configuration mkdir -p /home/ec2-user cd /home/ec2-user Create a file called aws_ec2.yml with the following content: plugin: amazon.aws.aws_ec2 regions: - ap-south-1 filters: tag:Env...

Complete Guide to Backup and Restore Puppet Master Serve

Puppet Master Server Backup Guide 1. Prepare for Backup Ensure you have working backups of the Primary , Replica , and Compilers . Before initiating the backup, stop the pe_databases module timers to prevent pg_repack from interfering: systemctl stop pe_databases-*.timer 2. Create Backup Run the backup command on the Primary server: sudo puppet-backup create --dir=<BACKUP_DIRECTORY> --name=<BACKUP_NAME> 3. Backup Secret Keys Secure the secret keys used by Orchestration and LDAP services: Orchestration: /etc/puppetlabs/orchestration-services/conf.d/secrets/ LDAP (if applicable): /etc/puppetlabs/console-services/conf.d/secrets/keys.json 4. Restart Database Timers systemctl start pe_databases-catalogs.timer pe_databases-facts.timer pe_databases-other.timer systemctl status pe_databases-*.timer Puppet Master Server Restore Guide 1. Stop Database Timers systemctl stop pe_databases-*.timer 2. Uninstall PE on the Restore Target sudo /opt/pupp...

Double the Tomcat: Run Two Instances on One Server

Creating a Custom Unit File for a Second Instance of Apache Tomcat Need to run multiple instances of Tomcat on the same machine? You can set up a second instance by duplicating the configuration and customizing key parameters to avoid conflicts with the first instance. Step-by-Step Procedure 1. Duplicate the Tomcat Installation Start by copying the existing Tomcat directory (typically /opt/tomcat ): # cp -r /opt/tomcat /opt/tomcat-second This creates an independent folder for the second instance, which you can configure separately. 2. Customize Ports and Settings Edit /opt/tomcat-second/conf/server.xml and modify ports to avoid clashes with the default instance. For example: HTTP Connector: Change port="8080" to port="8081" Shutdown Port: Change port="8005" to something like port="8006" AJP Connector: Change port="8009" to port="8010" 3. Create a Custom systemd Un...

Linux Process Termination Signals Explained with Examples

Linux uses signals to communicate with processes, allowing them to terminate, pause, or handle specific events. Below are key termination signals, examples of how to use them, and their effects. 1. SIGINT (2) : Interrupt Signal Default Action : Terminate the process. Trigger : Press Ctrl+C in the terminal. Use Case : Gracefully stop a running command (e.g., a script or program). Example: # Start a long-running process sleep 100 # Press Ctrl+C to send SIGINT and terminate it Handling SIGINT in a Bash Script: #!/bin/bash trap 'echo "SIGINT caught! Exiting..."; exit' SIGINT echo "Running... Press Ctrl+C to test SIGINT" while true; do sleep 1 done Output: Running... Press Ctrl+C to test SIGINT ^CSIGINT caught! Exiting... 2. SIGQUIT (3) : Quit Signal Default Action : Terminate and generate a core dump. Trigger : Press Ctrl+\ in the terminal. Use Case : Debugging (generates a core dump for post-mortem analysis). ...

Fix: SSH Permission Denied Issue | Real Solution

1. Verify SSH Command and Key Usage Use the correct private key with -i : ssh -i ~/.ssh/your_private_key user@host Ensure the key is not passphrase-protected (or enter the passphrase correctly). 2. Check Key Generation and Deployment Regenerate Keys (if unsure): ssh-keygen -t ed25519 -C "your_email@example.com" # Prefer ed25519 Ed25519 uses elliptic curve cryptography (Edwards-curve Digital Signature Algorithm) and provides 128-bit security (equivalent to RSA-3072 or RSA-4096) with a 256-bit key. Copy the Public Key to the Server: ssh-copy-id -i ~/.ssh/your_public_key user@host If ssh-copy-id isn’t available, manually append the public key to ~/.ssh/authorized_keys on the server. 3. Fix File/Directory Permissions On the Server: chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys chmod go-w ~ # Home directory should not be world-writable On the Client (Local Machine): chmod 600 ~/.ssh/your_private_key 4. Check SSH Server Configuration Edit /etc/ssh/s...