<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adarsha MV on Medium]]></title>
        <description><![CDATA[Stories by Adarsha MV on Medium]]></description>
        <link>https://medium.com/@adarshamv10?source=rss-a23776c2addc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BTQGWZaGO7_i8nPs</url>
            <title>Stories by Adarsha MV on Medium</title>
            <link>https://medium.com/@adarshamv10?source=rss-a23776c2addc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 07:03:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adarshamv10/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Writing Playbooks and Installing Packages on Slave Nodes-part3]]></title>
            <link>https://medium.com/@adarshamv10/writing-playbooks-and-installing-packages-on-slave-nodes-part3-f5e32e39edfe?source=rss-a23776c2addc------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e32e39edfe</guid>
            <dc:creator><![CDATA[Adarsha MV]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 17:58:01 GMT</pubDate>
            <atom:updated>2024-08-20T15:01:56.468Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous parts of this series, we discussed the basics of Ansible, and how to install and set up master and slave nodes. If you haven’t read those sections yet, please take a moment to go through them to ensure you have the necessary foundation-</p><ul><li>Part 1: <a href="https://medium.com/@adarshamv10/ansible-overview-part1-2e42512d800c">https://medium.com/@adarshamv10/ansible-overview-part1-2e42512d800c</a></li><li>Part 2: <a href="https://medium.com/@adarshamv10/ansible-installation-and-setting-up-master-and-slave-nodes-with-ssh-part2-e56bdf933af3">https://medium.com/@adarshamv10/ansible-installation-and-setting-up-master-and-slave-nodes-with-ssh-part2-e56bdf933af3</a></li></ul><p>Now, let’s dive into one of the most powerful features of Ansible: Playbooks. Playbooks allow you to automate tasks across your nodes with ease, ensuring consistency and reducing the potential for human error.</p><p><strong>What is a Playbook?<br></strong>A playbook in Ansible is a YAML file containing a list of tasks that automate processes on remote nodes. Playbooks are essential as they provide a structured way to define and manage the automation of complex tasks.</p><p><strong>Structure of a Playbook<br></strong>The structure of a playbook includes several key components:</p><ul><li><strong>Hosts</strong>: The target nodes where tasks will be executed.</li><li><strong>Tasks</strong>: The list of actions to be performed on the hosts.</li><li><strong>Variables</strong>: Dynamic values used within tasks.</li><li><strong>Handlers</strong>: Special tasks triggered by other tasks.</li></ul><p><strong>Here’s a simple example of a playbook structure:</strong></p><pre>---<br>- name: Simple Playbook Example<br>  hosts: group_name<br>  tasks:<br>    - name: Install a package<br>      apt:<br>        name: vim<br>        state: present</pre><p><strong>Writing Your First Playbook<br></strong>Let’s guide you through writing your first playbook. We’ll start with a simple task such as updating the package list and installing a package (e.g., Java or MySql).</p><p>Create a Playbook File<br>Open a text editor and create a new file named firstPlaybook.yml.</p><pre>--- <br>- name: installation of Java<br>  hosts: dest1<br>  become: true <br>  tasks:<br>    - name: Install Java <br>      apt: name=openjdk-11-jdk state=latest update_cache=yes <br><br>- name: installation of MySql <br>  hosts: dest2<br>  become: true <br>  tasks: <br>   - name: Install MySql <br>     apt: name=mysql-server state=latest update_cache=yes </pre><p><strong>Explanation of the Playbook</strong></p><ul><li><strong>name</strong>: A description of the playbook.</li><li><strong>hosts</strong>: Specifies the target group defined in the inventory file (in this case, slaves).</li><li><strong>become:</strong> Allows privilege escalation (i.e., running tasks as root).</li><li><strong>tasks</strong>: A list of tasks to be executed.</li></ul><p><strong>Creating an Inventory File<br></strong>Before running any playbook, you need to define the inventory file which lists the hosts and groups of hosts on which the tasks will be executed. Here’s how you create an inventory file:</p><p><strong>Create a New File:</strong></p><ul><li>Open a text editor and create a new file named inventory.</li></ul><p><strong>Define Hosts and Groups:</strong></p><ul><li>Add the following content to the inventory file to define the master and slave nodes:</li></ul><pre>[Group_name1]<br>Your_IP_Address_Slave1<br>[Group_name2]<br>Your_IP_Address_Slave2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*-eZISrpzoxOJYfREchpYRA.png" /><figcaption>For Example</figcaption></figure><p>This inventory file defines one slave nodes.</p><p><strong>Running the Playbook<br></strong>To run the playbook, use the ansible-playbook command:</p><pre>ansible-playbook -i inventory firstPlaybook.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*8ojxzCxIrBNfuTFdfe5vbw.png" /><figcaption>For Example</figcaption></figure><p><strong>Testing and Debugging Playbooks</strong></p><p>Testing and debugging are crucial parts of working with Ansible. Use the — check mode to simulate playbook execution:</p><pre>ansible-playbook -i inventory firstPlaybook.yml --check</pre><p>Use -v for verbose output to help with debugging:</p><pre>ansible-playbook -i inventory firstPlaybook.yml -v</pre><p><strong>Verifying Package Installation</strong></p><p>After running the playbook, it’s important to verify that the packages have been installed correctly on the slave node.</p><p>you can check the version of the installed packages:</p><pre>java --version<br>mysql --version</pre><p><strong>Deploying a Static HTML Page</strong></p><p>Now, let’s write playbook to deploy a static HTML page using Ansible. We will copy an HTML file to the web server’s root directory and ensure the Nginx service is running to serve the page.</p><p><strong>Create the HTML File<br></strong>First, create a simple HTML file named <strong>index.html</strong>:</p><pre>&lt;!-- index.html --&gt; <br>&lt;!DOCTYPE html&gt; <br>&lt;html&gt; <br>&lt;head&gt; <br>    &lt;title&gt;Welcome to Ansible Deployment&lt;/title&gt; <br>&lt;/head&gt; <br>&lt;body&gt; <br>    &lt;h1&gt;Hello World&lt;/h1&gt; <br>&lt;/body&gt; <br>&lt;/html&gt; </pre><p><strong>Create a Playbook for Deploying the HTML Page<br></strong>Next, create a playbook file named playbook1.yml:</p><pre>--- <br>- name: Deploy static page with Nginx <br>  hosts: dest1<br>  become: true <br>  <br>  tasks: <br>    - name: Update apt cache <br>      apt: <br>        update_cache: yes <br><br>    - name: Install Nginx <br>      apt: <br>        name: nginx <br>        state: present <br><br>    - name: Start and enable Nginx <br>      systemd: <br>        name: nginx <br>        state: started <br>        enabled: true <br><br>    - name: Deploy static HTML page <br>      copy: <br>        src: /home/Your_Path/index.html <br>        dest: /var/www/html/index.html <br><br>    - name: Ensure Nginx is running <br>      service: <br>        name: nginx <br>        state: started </pre><p><strong>Explanation of the Playbook</strong></p><ul><li><strong>name</strong>: A description of the playbook.</li><li><strong>hosts</strong>: Specifies the target group defined in the inventory file (in this case, slaves).</li><li><strong>become</strong>: Allows privilege escalation.</li><li><strong>tasks:</strong> A list of tasks to be executed.</li><li>Install Nginx.<br>Ensure Nginx service is started and enabled.<br>Copy the HTML file to the web server’s root directory.</li><li><strong>handlers:</strong> A special task to restart Nginx if the HTML file is copied.</li></ul><p><strong>Running the Playbook</strong></p><p>To run the playbook, use the ansible-playbook command:</p><pre>ansible-playbook -i inventory playbook1.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*G9i014f9uOsCtyJuuFW1OQ.png" /><figcaption>For Example</figcaption></figure><p><strong>Verifying the Deployment</strong></p><p>After running the playbook, verify that the static HTML page is deployed correctly:</p><p><strong>SSH into a Slave Node: </strong>Connect to one of your slave nodes via SSH.</p><pre>ssh user_Name@slave-node-ip</pre><p><strong>Check the HTML File:</strong> Ensure the HTML file is present in the web server’s root directory.</p><pre>ls /var/www/html/index.html</pre><p><strong>Access the Web Page:</strong> Open a web browser and navigate to the IP address of the slave node. You should see the static HTML page displayed.</p><pre>http://slave-node-ip</pre><ul><li><strong>Note</strong>: before going to run this in browser allow the inbound port 80.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*cgZKMKJizU741R0DZC6rZg.png" /><figcaption>Output of that static html file</figcaption></figure><p><strong>Conclusion<br></strong>In this final part of our series, we’ve covered the basics of writing Ansible playbooks, how to install packages on slave nodes, and how to deploy a static HTML page. We’ve also discussed verifying installations and deployment, as well as some best practices.</p><p>Thank you for following along with this series on Ansible. We hope you found it informative and useful for your automation tasks. happy automating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e32e39edfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible Installation and Setting Up Master and Slave Nodes with SSH-Part2]]></title>
            <link>https://medium.com/@adarshamv10/ansible-installation-and-setting-up-master-and-slave-nodes-with-ssh-part2-e56bdf933af3?source=rss-a23776c2addc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e56bdf933af3</guid>
            <dc:creator><![CDATA[Adarsha MV]]></dc:creator>
            <pubDate>Wed, 05 Jun 2024 13:48:00 GMT</pubDate>
            <atom:updated>2024-06-20T01:49:51.151Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to Part 2 of our Ansible series. In this section, we will cover how to install Ansible and set up SSH connections between your master (control node) and slave (managed nodes) machines. If you haven’t read Part 1 yet, I recommend checking it out <a href="https://medium.com/@adarshamv10/ansible-overview-part1-2e42512d800c">https://medium.com/@adarshamv10/ansible-overview-part1-2e42512d800c</a> for an overview of Ansible and its basic concepts.</p><p><strong>Prerequisites</strong></p><ul><li>Two Linux servers: one for the master and another for the slave.</li><li>Basic knowledge of Linux commands.</li></ul><p><strong>Setting Up the Master and Slave Servers</strong></p><p>Before setting up the nodes, we need to install Ansible on our master node. Follow these steps to get Ansible up and running.</p><p><strong>Login to your master node</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*fq5K4QHkmDu4jsf-xCVuvg.png" /></figure><p><strong>Installing Ansible on the Master Node</strong></p><pre>sudo apt update<br>sudo apt install ansible<br>ansible --version</pre><p><strong>Setting Up SSH Connections</strong></p><p>To manage other machines with Ansible, we need to set up SSH connections from the master node to the slave nodes. Here’s how you can do it:</p><p><strong>Generate an SSH Key on the master node</strong></p><pre>ssh-keygen</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2rGlATfdpgMNWH4rKz1xNg.png" /></figure><p><strong>Display the SSH Public Key</strong></p><pre>cat /home/Your_path/.ssh/id_rsa.pub</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aJa3iRbLReVteAhxq3KwOg.png" /></figure><p><strong>Copy the Public Key to the Slave Nodes:</strong></p><p>First generate the ssh-keygen in slave node also.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pG0wN5VWa5PAnyZbC3b_jg.png" /></figure><p>Redirect to the .ssh directory and open the authorized_keys file using vi command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6WScexHevp1ycx1i_YjAtQ.png" /></figure><p>paste that public key where you copied from master node in authorized_keys file and save the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SJRHVYBqfLmVZOgiaeN1Ig.png" /></figure><p><strong>Verify SSH Connection:</strong></p><pre>ssh ansible-slave<br>or<br>ssh Your_Slave_Node_IP</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*L15dan6lT8GrVGhG8pPY9A.png" /><figcaption>verifying with slave server name</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*VQNhvr-NtFpRi6Zngb--FA.png" /><figcaption>Verifying with slave server IP</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e56bdf933af3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible Overview-Part1]]></title>
            <link>https://medium.com/@adarshamv10/ansible-overview-part1-2e42512d800c?source=rss-a23776c2addc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e42512d800c</guid>
            <dc:creator><![CDATA[Adarsha MV]]></dc:creator>
            <pubDate>Mon, 03 Jun 2024 18:09:28 GMT</pubDate>
            <atom:updated>2024-06-04T06:45:59.700Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to my blog series on Ansible, designed to help you understand and effectively use this powerful automation tool. This series is divided into three comprehensive parts:</p><p><strong>Part 1</strong>: Overview of Ansible.</p><p><strong>Part 2:</strong> Ansible Installation and Setting Up Master and Slave Nodes with SSH.</p><p><strong>Part 3</strong>: Writing Playbooks and Installing Packages on Slave Nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*sNyxq09IkzTPqfh5sBf2Aw.jpeg" /></figure><ul><li>Note: If you’re already familiar with Ansible, this blog might not be for you. But if you don’t know anything about Ansible and want to learn, you’re in the right place. Just follow along with this blog to get started.</li></ul><p><strong>What is Ansible?</strong></p><p>Ansible is an open-source automation tool used for IT tasks such as configuration management, application deployment, and task automation. It simplifies complex tasks and makes them repeatable, reliable, and efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*iGujPJjjAuVUR-kXexlfFg.png" /></figure><p><strong>Why Use Ansible?</strong></p><p><strong>Simplicity</strong>: Ansible uses simple, human-readable YAML syntax for its playbooks, making it easy to write and understand.</p><p><strong>Agentless</strong>: Unlike other tools, Ansible doesn’t require any software or agents to be installed on the nodes (machines) it manages.</p><p><strong>Efficient</strong>: Ansible connects to nodes over SSH, making it lightweight and fast.</p><p><strong>Idempotent</strong>: Ansible ensures that operations only make changes when necessary, avoiding redundant tasks.</p><h4><strong>Key Concepts of Ansible</strong></h4><p><strong>Control Node</strong>: This is the machine where Ansible is installed and from where tasks are executed.</p><p><strong>Managed Nodes:</strong> These are the machines that Ansible controls.</p><p><strong>Inventory</strong>: A file that lists all the managed nodes. It can be a simple text file with IP addresses or hostnames.</p><p><strong>Modules</strong>: Units of work that Ansible executes. Examples include tasks like installing packages, managing services, or copying files.</p><p><strong>Playbooks</strong>: YAML files where you define automation tasks. Playbooks are a collection of plays that define the desired state of managed nodes.</p><p><strong>Roles</strong>: A way to organize playbooks and other files to facilitate sharing and reuse.</p><p><strong>Benefits of Using Ansible</strong></p><p><strong>Consistency</strong>: Ensures that the environment setup is the same every time it is run.</p><p><strong>Scalability</strong>: Can manage thousands of machines at once.</p><p><strong>Flexibility</strong>: Can handle complex deployments and custom workflows.</p><p><strong>Common Use Cases</strong></p><p><strong>Configuration Management</strong>: Ensuring that all systems are configured properly and consistently.</p><p><strong>Application Deployment</strong>: Automating the deployment of applications and services.</p><p><strong>Orchestration:</strong> Managing the ordering and coordination of interdependent tasks across multiple machines.</p><p><strong>Continuous Delivery</strong>: Integrating with CI/CD pipelines for automated deployments.</p><p><strong>Conclusion</strong></p><p>Ansible is a powerful tool for IT automation. Its simplicity and efficiency make it a favourite among developers and system administrators. Whether you’re managing a few servers or thousands, Ansible can help you automate your tasks and ensure consistency across your infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e42512d800c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>