<?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 Sayali Shewale on Medium]]></title>
        <description><![CDATA[Stories by Sayali Shewale on Medium]]></description>
        <link>https://medium.com/@sayalishewale12?source=rss-d240e17bfeda------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KLZTlcxoDHQKa9qJSpLzNA.jpeg</url>
            <title>Stories by Sayali Shewale on Medium</title>
            <link>https://medium.com/@sayalishewale12?source=rss-d240e17bfeda------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 19:21:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sayalishewale12/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[Complete Guide to Creating and Pushing Docker Images to Amazon ECR]]></title>
            <link>https://medium.com/@sayalishewale12/complete-guide-to-creating-and-pushing-docker-images-to-amazon-ecr-70b67ac1ab4c?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/70b67ac1ab4c</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-ecr]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[container-registry]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 08:01:39 GMT</pubDate>
            <atom:updated>2024-03-04T08:01:39.975Z</atom:updated>
            <content:encoded><![CDATA[<h4>Step1 : Set up AWS CLI</h4><p>Install AWS CLI on your machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UR-IO5U1rBqV65Fk5FVcA.png" /></figure><h4>Step2: Create an IAM User</h4><p>In AWS management console, Go to IAM service, create an IAM user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MYKQMotJCn3i2SNdp5JbPQ.png" /></figure><p>Attach policies to the user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TxPr-uPjmp71_3SO_5rDA.png" /></figure><p>User is created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGllnKggmyO2ptjQtVcWZQ.png" /></figure><p>Go to security credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXI3h9SSi7IbNzdbV3wtzA.png" /></figure><p>Click on create access key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ju1z7NYyXIPP_r8uugIdQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jj8okHtj3przbkR-1MYAIA.png" /></figure><p>Download .csv file which contain access key and secret access key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjaoMR3XAjNlq8444jzPXA.png" /></figure><h4>Step 3: Configure AWS CLI</h4><p>Enter AWS access key, secret access key , default region and default output format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M4EbuMwdOuD98UHFbm4NLw.png" /></figure><h4>Step 4: Create an ECR Repository</h4><p>You can create Repository using AWS management console or AWS cli.</p><p>Run the following command to create a new ECR repository using AWS cli. Replace repository-name with your desired repository name.</p><pre>aws ecr create-repository --repository-name your-repository-name</pre><p>Go to AWS management console, then go to Amazon ECR service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzjA_YGoyToDTjytrvCTVw.png" /></figure><p>In the Amazon ECR console, select “Repositories” from the left navigation pane.</p><p>Click the “Create repository” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqkUt8zWzUeh20UqUL5C0Q.png" /></figure><p>Enter a unique name for your repository in the “Repository name” field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-QUWpJYWUs3uL8kVbAs6Q.png" /></figure><p>Click the “Create repository” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJ0FSB-rUq79elu8mpvCug.png" /></figure><p>Repository is created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8h_FPNFcqHt855RnKtLMQ.png" /></figure><h4>Step 5: Build Docker Image Locally</h4><p>Using your machine, navigate to the directory containing your Dockerfile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uGcxUkfvypb7A57-B2EIg.png" /></figure><p>Build your Docker image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGunTPqf0pF27y2N17fdUA.png" /></figure><p>docker image is created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xt1dmvptnQCv1RousceeJg.png" /></figure><h4>Step 6: Push Docker Image to ECR</h4><p>1. Go back to the AWS Management Console.</p><p>2. In the Amazon ECR console, select your repository from the list.</p><p>3. In the repository details, click the “View push commands” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYeM_1MGwY8Gnpo-44GcJA.png" /></figure><p>4. Follow the provided instructions to authenticate Docker with your ECR registry and push your Docker image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7edZ_VJdnvAi_ozvXxWVXQ.png" /></figure><ol><li>Retrieve an authentication token and authenticate your Docker client to your registry. Use the AWS CLI:</li></ol><pre>aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 211125656815.dkr.ecr.ap-south-1.amazonaws.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n77h6MDBn7IOMKLgyrOLKA.png" /></figure><p>2. Build your Docker image using the docker build command. You can skip this step if your image is already built.</p><p>3. After the build completes, tag your image so you can push the image to this repository:</p><pre>docker tag demo-app:latest 211125656815.dkr.ecr.ap-south-1.amazonaws.com/demo-app:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oe5mTs7BCXpRapM6aZwreQ.png" /></figure><p>4. Run the following command to push this image to your newly created AWS repository:</p><pre>docker push 211125656815.dkr.ecr.ap-south-1.amazonaws.com/demo-app:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CauPOvTS8ohhpYeY1pUgbw.png" /></figure><h4>Step 7: Verify Image in ECR Console</h4><p>Once the image is pushed, go back to the Amazon ECR console. Select your repository.</p><p>Check the “Images” tab to verify that your Docker image has been successfully pushed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxmqTKj1gwt5G0OoyA4BsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GRrZJ4kfevjeBx8QIrT-pA.png" /></figure><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70b67ac1ab4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform Variables: A Quick Guide]]></title>
            <link>https://medium.com/@sayalishewale12/terraform-variables-a-quick-guide-abeb26ba84a3?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/abeb26ba84a3</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[terraform-variable]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Wed, 29 Nov 2023 13:05:31 GMT</pubDate>
            <atom:updated>2023-11-29T13:05:31.068Z</atom:updated>
            <content:encoded><![CDATA[<p>In Terraform, variables are used to pass values from external sources into Terraform configuration. They provide a way to configure the infrastructure without hardcoding values directly into the configuration. Variables in Terraform are quite important, as you need to hold values of names of instance, configs etc.</p><p>We can create a variables.tf file which will hold all the variables.</p><pre>variable &quot;filename&quot; {<br>default = &quot;/home/ubuntu/terraform/terraform-variable/var-demo.txt&quot;<br>}<br>variable &quot;content&quot; {<br>default = &quot;This is terraform variable demo file&quot;<br>}</pre><h3>Task-01</h3><p>Create a local file using Terraform.</p><p>Create a variable.tf file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ec8DLmrIWSO802tX" /></figure><p>The filename variable has a default value of /home/ubuntu/terraform/terraform-variable/var-demo.txt, which is the path and filename where the local file will be created.</p><p>The content variable has a default value of “This is terraform variable demo file”, which is the text that will be written to the local file.</p><p>Create a main.tf file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S4_9B072l1qD6PfR" /></figure><p>Terraform code block creates a local_file resource named “devops” that writes a file to disk with the filename and content specified by the filename and content variables.</p><p>Initializes a new or existing terraform working directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pXI-ZbOnG0mVf_u0" /></figure><p>Generates an execution plan that shows what actions terraform will take to reach the desired state specified in the configuration file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OFqtXEsGHj4jh1ba" /></figure><p>When you run terraform apply, Terraform will create a file called var-demo.txt in the local directory with the content specified in the content variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RjXGBmFmEpJhWIhj" /></figure><p>Check file is created in specified folder using ls command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wrur2LsXY1LGlkrK" /></figure><h3>Data Types in Terraform</h3><h4><strong>1. Map</strong></h4><pre>variable &quot;file_contents&quot; {<br>type = map<br>default = {<br>&quot;statement1&quot; = &quot;this is cool&quot;<br>&quot;statement2&quot; = &quot;this is cooler&quot;<br>}<br>}</pre><h3>Task-02</h3><p>Use terraform to demonstrate usage of List, Set and Object datatypes</p><p>Put proper screenshots of the outputs</p><p>Map:</p><p>A map is a collection of values where each value is identified by a string label</p><p>variable.tf</p><pre>variable &quot;content_map&quot; {<br>type = map<br>default = {<br>&quot;content1&quot; = &quot;this is cool content1&quot;<br>&quot;content2&quot; = &quot;this is cooler content2&quot;<br>}<br>}</pre><p>In the example, a map variable named content_map is defined with a default value of two key-value pairs. The keys are strings and the values are also strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L153uIDTnyUn-gAy" /></figure><p>This variable can be used in your Terraform configuration to reference the values associated with each key defined in the map. For example, you might use it to configure a resource that requires content,</p><pre>resource &quot;local_file&quot; &quot;devops&quot; {<br>    filename = &quot;/home/ubuntu/terraform/terraform-variable/type-map/demo.txt&quot;<br>    content = var.content_map[&quot;content1&quot;]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6WSsI0NDPUGwJo2y" /></figure><p>In this example, we use the content_map variable to set the content parameter of local_file resource. We reference the value associated with the key “content1” using the dot notation and var.content_map[“content1”] syntax.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nqt5ca2mrSWkT40x" /></figure><p>terraform plan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*23cZtSqhNl1bTr_C" /></figure><p>terraform apply</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SdTcVZSunJccfS03" /></figure><p>Check demo.txt file content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WKnSLJoAwuOBCM4d" /></figure><h4>2. List:</h4><p>A list is an ordered collection of values of the same type. To define a list variable, use the list type and specify the type of elements in the list. Here’s an example:</p><pre>variable &quot;file_list&quot;{<br>type = list<br>default = [&quot;/home/ubuntu/terraform/terraform-variable/type-map/file1.txt&quot;,&quot;/home/ubuntu/terraform/terraform-variable/type-map/file2.txt&quot;]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9J9yMs-IQp4LI6_N" /></figure><p>In this example, we define a variable named “file_list” as a list of strings with a default value which contain files path.</p><p>This variable can be used in your Terraform configuration to reference the file paths defined in the list.</p><pre>resource &quot;local_file&quot; &quot;devops&quot; {<br>    filename = var.file_list[0]<br>    content = var.content_map[&quot;content1&quot;]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rVmbmnRP4ttbZeL0" /></figure><p>In this example, we use the file_list variable to set the filename parameter of an local_file resource. We reference the first element of the list using the square bracket notation and var.file_list[0] syntax.</p><p>Terraform plan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KPLA52EoSSDMuPN3" /></figure><p>Terraform apply</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pvse-UhOnSK2L1Z6" /></figure><p>Check 2 files created with different content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ITVX8_Nv_XXlrVf6" /></figure><h4>3. Object:</h4><p>An object is a structural type that can contain different types of values, unlike map, list. It is a collection of named attributes that each have their own type.</p><p>In the example, an object variable named aws_ec2_object is defined with a default value of a set of properties for an EC2 instance.</p><p>This variable can be used in your Terraform configuration to reference the individual properties of the EC2 instance defined in the object.</p><pre>variable &quot;aws_ec2_object&quot; {<br>    type = object({<br>        name = string<br>        instances = number<br>        keys = list(string)<br>        ami = string<br>})<br></pre><pre>default = {<br>    name = &quot;test-ec2-instance&quot;<br>    instances = 4<br>    keys = [&quot;key1.pem&quot;,&quot;key2.pem&quot;]<br>    ami = &quot;ubuntu-bfde24&quot;<br>}<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B4VOx_onzzaaT6gb" /></figure><p>main.tf</p><p>This output can be used to display the value of the ami property in the Terraform output after applying the configuration.</p><pre>output &quot;aws-ec2-instances&quot;{<br>    value = var.aws_ec2_object.ami<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*agHBesyINlEDUjxm" /></figure><p>terraform plan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bcxmZNMd50aKzvl6" /></figure><p>terraform apply</p><p>you can see output of aws-ec2-instance value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7cmA3--K8venHVQV" /></figure><h4>4. Set:</h4><p>A set is an unordered collection of unique values of the same type. To define a set variable, use the set type and specify the type of elements in the set. Here’s an example:</p><pre>variable &quot;security_groups&quot; {<br>  type    = set<br>  default = [&quot;sg-12345678&quot;, &quot;sg-87654321&quot;]<br>}</pre><p>In this example, we define a variable named “security_groups” as a set of strings with a default value.</p><h3>Use terraform refresh</h3><p>To refresh the state by your configuration file, reloads the variables</p><p>terraform refresh is a Terraform command that retrieves the current state of the resources defined in your configuration and updates the Terraform state file to match that state.</p><p>By running terraform refresh, you can update the state file to reflect the current state of your resources, so that Terraform has an accurate view of what needs to be changed. This command does not make any changes to your resources, but simply updates the state file to match the current state of your resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g6GM--nN0t4VB53h" /></figure><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abeb26ba84a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform & Docker: Creating Images and Containers with Terraform]]></title>
            <link>https://medium.com/@sayalishewale12/terraform-docker-creating-images-and-containers-with-terraform-fc3f0364eb13?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc3f0364eb13</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Thu, 23 Nov 2023 12:53:29 GMT</pubDate>
            <atom:updated>2023-11-23T12:53:29.150Z</atom:updated>
            <content:encoded><![CDATA[<p>Terraform needs to be told which provider to be used in the automation, hence we need to give the provider name with source and version. For Docker, we can use this block of code in your main.tf</p><h3>Blocks and Resources in Terraform</h3><h3>Terraform block</h3><p><strong>Create a Terraform script with Blocks and Resources.</strong></p><pre>terraform {<br>  required_providers {<br>    docker = {<br>      source  = &quot;kreuzwerker/docker&quot;<br>      version = &quot;~&gt; 2.21.0&quot;<br>}<br>}<br>}</pre><p>This is a Terraform configuration block specifying the required Docker provider and its version.</p><p>In this configuration, you are specifying that your Terraform code requires the Docker provider to interact with Docker containers. The source parameter specifies the location of the provider code, which in this case is the kreuzwerker/docker GitHub repository. The version parameter specifies the minimum version of the provider that should be used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dc38G7WmsDIH5wiv" /></figure><h3>Provider Block</h3><p>The provider block configures the specified provider, in this case, docker. A provider is a plugin that Terraform uses to create and manage your resources.</p><pre>provider &quot;docker&quot; {}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lODn9Qf4Z7GY581l" /></figure><h3>Resource</h3><p>Use resource blocks to define components of your infrastructure. A resource might be a physical or virtual component such as a Docker container, or it can be a logical resource such as a Heroku application.</p><p>Resource blocks have two strings before the block: the resource type and the resource name. In this example, the first resource type is docker_image and the name is Nginx.</p><p><strong>Create a resource Block for an nginx docker image</strong></p><pre>resource &quot;docker_image&quot; &quot;nginx&quot; {<br> name         = &quot;nginx:latest&quot;<br> keep_locally = false<br>}</pre><p>Create a resource Block for running a docker container for nginx</p><pre>resource &quot;docker_container&quot; &quot;nginx&quot; {<br> image = docker_image.nginx.latest<br> name  = &quot;tutorial&quot;<br> ports {<br>   internal = 80<br>   external = 80<br> }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l6-ClCBYPxZH8wRy" /></figure><p>After creating a Terraform configuration file (with a .tf extension), use the following Terraform commands to provision and manage your infrastructure:</p><p><strong>Terraform init: </strong>Initializes a new or existing Terraform working directory by downloading and installing any required providers and modules, initializing the backend, and downloading any necessary plugins.</p><pre>terraform init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MW1V63S11gsnVwRR" /></figure><p><strong>Terraform plan: </strong>Generates an execution plan that shows what actions Terraform will take to reach the desired state specified in the configuration file. This command also reports any changes that will be made to the infrastructure.</p><pre>terraform plan</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hbukBo5YsQ1USJ6c" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NNa-06nPsYKpO3L0" /></figure><p><strong>Terraform apply:</strong> Executes the actions proposed in the execution plan generated by terraform plan. This command provisions and configures the infrastructure defined in the configuration file.</p><pre>terraform apply</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-y6bCg0r9ODCpgxM" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fuj4C4quj2_W-Jew" /></figure><p>In case Docker is not installed use below commands:</p><pre>sudo apt-get install docker.io <br>sudo docker ps <br>sudo chown $USER /var/run/docker.sock</pre><p>Check docker container is created using below command:</p><pre>docker ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ShuMKq89uRfLXBPd" /></figure><p>Browse public IP address, you can see nginx default page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tc6T0uNta0FwVBRL" /></figure><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc3f0364eb13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Terraform: A Deep Dive into Commands and its Rivals]]></title>
            <link>https://medium.com/@sayalishewale12/mastering-terraform-a-deep-dive-into-commands-and-its-rivals-66feaf7dc610?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/66feaf7dc610</guid>
            <category><![CDATA[terraform-command]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 13:10:56 GMT</pubDate>
            <atom:updated>2023-10-21T13:11:41.509Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Find purpose of basic Terraform commands which you’ll use often.</strong></h4><p><strong>1.terraform init:</strong></p><p>Initializes a new or existing Terraform working directory by downloading the required provider plugins and sets up the backend to store the state. This command must be run before any other Terraform command is executed.</p><p><strong>2.terraform init -upgrade</strong>:</p><p>Upgrades the configuration to the latest version of Terraform. This is useful if you’ve upgraded your Terraform version and want to ensure that your configuration is compatible with the new version.</p><p><strong>3.terraform plan:</strong></p><p>Shows the changes that Terraform will make to the infrastructure to bring it into the desired state, without actually making the changes. This is useful to see what changes Terraform will make before actually applying them.</p><p><strong>4.terraform apply:</strong></p><p>Applies the changes to the infrastructure described in the Terraform configuration file. This command will create, modify, or delete resources as needed to bring the infrastructure into the desired state.</p><p><strong>5.terraform validate:</strong></p><p>Validates the syntax and structure of the Terraform configuration file. This command checks for errors, missing required arguments, and other issues.</p><p><strong>6.terraform fmt:</strong></p><p>Rewrites Terraform configuration files to a canonical format, which makes it easier to read and maintain.</p><p><strong>7.terraform destroy:</strong></p><p>Destroys all the infrastructure created by Terraform, freeing up resources and ensuring that you’re not paying for unused infrastructure. This command should be used with caution as it will delete all the resources described in the configuration file.</p><h3>What are the main competitors of Terraform?</h3><p><strong>AWS CloudFormation:</strong> AWS CloudFormation is an IaC tool provided by Amazon Web Services (AWS). It allows users to define and manage infrastructure resources in a declarative way using JSON or YAML templates. CloudFormation supports a wide range of AWS services and is tightly integrated with other AWS tools and services.</p><p><strong>Ansible:</strong> Ansible is an open-source IaC tool that uses YAML scripts to define and manage infrastructure resources. Ansible can be used for provisioning, configuration management, and application deployment across multiple platforms and cloud providers.</p><p><strong>Kubernetes:</strong> Kubernetes is another IT automation alternative to Terraform. It is an open-source solution that enables automated deployment, management, and scaling of containerized applications. It simplifies container communication. It facilitates container discovery and management within an application.</p><p><strong>Puppet</strong>: Puppet is another open-source IaC tool that uses a declarative language to define and manage infrastructure resources. Puppet has a large community of users and contributors and supports a wide range of platforms and cloud providers.</p><p><strong>Chef:</strong> Chef is an open-source IaC tool that uses Ruby scripts to define and manage infrastructure resources. Chef is particularly well-suited for managing large-scale infrastructures and supports a wide range of platforms and cloud providers.</p><p><strong>Packer:</strong> Packer create identical machine images for multiple platforms from a single source configuration. A common use case is creating golden images for organizations to use in cloud infrastructure.</p><p><strong>Cloud Foundry:</strong> Cloud Foundry is an open source cloud application platform that makes it faster and easier to build, test, deploy, and scale apps in your choice of cloud, framework, and language. Remove the cost and complexity associated with configuring, managing, and securing infrastructure for your app with Cloud Foundry.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66feaf7dc610" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Infrastructure as Code with Terraform]]></title>
            <link>https://aws.plainenglish.io/infrastructure-as-code-with-terraform-301cfd6c0ff3?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/301cfd6c0ff3</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Mon, 09 Oct 2023 13:18:59 GMT</pubDate>
            <atom:updated>2023-10-19T11:46:50.675Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Terraform?</h3><p>Terraform is an infrastructure as code (IaC) tool that allows you to create, manage, and update infrastructure resources such as virtual machines, networks, and storage in a repeatable, scalable, and automated way.</p><h3>Task 1:</h3><p>Install Terraform on your system.</p><p>Create an EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HTFskf56wMB3PGFx" /></figure><p>SSH into your Ubuntu EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wFKx_2c4tGwL6g9h" /></figure><p>Download the appropriate package for your system from the official Terraform website (<a href="https://www.terraform.io/downloads.html">https://www.terraform.io/downloads.html</a>).</p><p>Select Linux as the operating system and Ubuntu as the package manager.</p><p>Copy and paste below three commands to instance terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q4K8-V8F1DzeXO_a" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9imQb0fttp1vax28" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BIYe2anf-hsFJPI9" /></figure><p>Install Terraform by running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9OGhsivNjb41_dtW" /></figure><p>Verify that Terraform is installed correctly by running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EZjKc9eZvcmFkxzZ" /></figure><h3>Task 2: Answer below questions</h3><p><strong>Why we use terraform?</strong></p><p>Terraform is a tool for building, changing, and versioning infrastructure in a safe, repeatable way. It enables teams to manage infrastructure as code, providing a single source of truth for the infrastructure and ensuring that it is always in the desired state. Terraform can be used to manage infrastructure across multiple cloud providers and on-premises infrastructure, and it supports a wide range of resource types.</p><p><strong>What is Infrastructure as Code (IaC)?</strong></p><p>Infrastructure as Code (IaC) is a practice of managing and provisioning infrastructure using code instead of manual processes. By treating infrastructure as code, teams can version control their infrastructure, automate the provisioning process, and improve collaboration between different teams. IaC enables teams to make changes to infrastructure in a safe and repeatable way, and it helps to reduce the risk of human error and inconsistencies.</p><p><strong>What is Resource?</strong></p><p>In Terraform, a resource is a declarative representation of a component in a cloud infrastructure, such as a virtual machine, database, or network interface. Resources define the desired state of the component, and Terraform uses the resource definition to create, modify, or delete the component as needed.</p><p><strong>What is Provider?</strong></p><p>In Terraform, a provider is a plugin that interfaces with a specific cloud infrastructure provider or service. Providers define the resources that Terraform can manage, as well as the methods for creating, updating, and deleting those resources. Examples of providers include AWS, Google Cloud, and Microsoft Azure.</p><p><strong>What is State file in terraform? What’s the importance of it ?</strong></p><p>The Terraform state file is a JSON file that stores the state of the infrastructure managed by Terraform. It includes information about the resources that have been created, their current state, and any dependencies between them. The state file is critical to Terraform’s operation, as it is used to plan and execute changes to the infrastructure. The state file should be kept in a safe and secure location, as it contains sensitive information about the infrastructure.</p><p><strong>What is Desired and Current State?</strong></p><p>In Terraform, the desired state is the state that you want your infrastructure to be in, as defined in your Terraform configuration files. The current state is the actual state of the infrastructure, as represented in the Terraform state file. When you run terraform apply, Terraform compares the desired state with the current state and makes changes as needed to bring the infrastructure into the desired state.</p><p>Thank you for reading!</p><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><strong><em>(X</em></strong>), <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, and <a href="https://discord.gg/in-plain-english-709094664682340443"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=301cfd6c0ff3" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/infrastructure-as-code-with-terraform-301cfd6c0ff3">Infrastructure as Code with Terraform</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible Project]]></title>
            <link>https://medium.com/@sayalishewale12/ansible-project-aa49fe0b1c0d?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa49fe0b1c0d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Sat, 07 Oct 2023 05:37:28 GMT</pubDate>
            <atom:updated>2023-10-07T05:37:28.694Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible playbooks are amazing, as you learned yesterday. What if you deploy a simple web app using Ansible, sounds like a good project, right?</p><h3>Task-01</h3><p>Create 3 EC2 instances. make sure all three are created with the same key pair.</p><p>To create 3 EC2 instances, navigate to the EC2 service and launch them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uxDdW5xQNa29m35u" /></figure><p>After creating the three EC2 instances, designate one instance as the Ansible control node (ansible_host), and the other two instances as managed nodes (ansible_server).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4MN7Mgy43IeNFgmA" /></figure><p>Install Ansible in host server</p><p>Connect to your EC2 instance using SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-XFJQ2GvQsIjogE1" /></figure><p>Add the Ansible PPA repository using the following command:</p><pre>sudo apt-add-repository ppa:ansible/ansible</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6fwluG_2OVUsAlm7" /></figure><p>Update the package using following commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WHZE3IAy3kB3C3pU" /></figure><p>Install Ansible using the following command:</p><pre>sudo apt install ansible</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YZqu_5mHr3QuAS25" /></figure><p>Once the installation is complete, you can check the version of Ansible using the following command:</p><pre>ansible --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2kaSkU-d3HCiUzbH" /></figure><p>Copy the private key from local to Host server (ansible_host) at (/home/ubuntu/.ssh)</p><p>Copy private key from your local.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VnQtAv6D-0Z-v3YE" /></figure><p>To proceed with the setup, copy the private key to the Ansible control node (ansible_host) by creating a new file at /home/ubuntu/.ssh and pasting the private key in that file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D4o88C3hnLDqix9M" /></figure><p>Give permissions to the private key file using chmod command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*gShJsK6kOcowVfur" /></figure><p>Access the inventory file using sudo nano /etc/ansible/hosts</p><p>Create inventory file at location /etc/ansible/hosts which is by default location of file. Ansible hosts file is a configuration file that contains a list of hosts or servers. Add the IP addresses of the servers also add private key file location to use for authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PmHtHUeLwf1eZRqu" /></figure><p>Create a playbook to install Nginx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C3WEgXNzd2NN4IfS" /></figure><p>In this playbook, we first specify the name of the playbook (Install nginx) and the hosts we want to target (servers). We also set become: yes to run the tasks with root privileges.</p><p>The first task updates the apt cache on the managed nodes using the apt module. The second task installs the latest version of Nginx using the same module. The third task uses the service module to start the Nginx service by specifying the service name (nginx) and setting the state parameter to started.</p><p>Run playbook using the ansible-playbook command</p><pre>ansible-playbook file-name.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-crdqq2JXL4HVlj1" /></figure><p>Check the status of Nginx on the two EC2 instances,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w5lgE0ekOClAp8-8" /></figure><p>Deploy a sample webpage using the ansible playbook</p><p>Create a new file index.html in the playbook directory, and add some sample content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O9cEMpoFRCBql4yG" /></figure><p>Update a ansible playbook file, install_nginx.yml, in the playbook directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*czhqUM8UqGZgxHAS" /></figure><p>This playbook will copy the index.html file to the default Nginx web server document root directory at /var/www/html/.</p><p>Run the playbook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v-ATaP7ZaBLaBy_J" /></figure><p>Once the playbook finishes executing, open a web browser and enter the public IP address of one of the EC2 instances running Nginx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F1-Wv-ZGbk7q0HXR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yJTnC-zt9PnQ-dvY" /></figure><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa49fe0b1c0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible Playbooks]]></title>
            <link>https://medium.com/@sayalishewale12/ansible-playbooks-0bf9336a6e19?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/0bf9336a6e19</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Tue, 03 Oct 2023 07:00:01 GMT</pubDate>
            <atom:updated>2023-10-03T07:00:01.261Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible playbooks run multiple tasks, assign roles, and define configurations, deployment steps, and variables. If you’re using multiple servers, Ansible playbooks organize the steps between the assembled machines or servers and get them organized and running in the way the users need them to. Consider playbooks as the equivalent of instruction manuals.</p><h3>Task-01</h3><h3>1. Write an ansible playbook to create a file on a different server</h3><p>Create an inventory file for Ansible</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/0*EUhDPN6dXJpuUbfC" /></figure><p>Create an ansible playbook to create a file on a different server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gUo_A1Gtg_QhcBPX" /></figure><p>In this playbook, we define a single task that uses the file module to create the file. The path parameter specifies the full path to the file we want to create, and state parameter set to touch which will create the file if it doesn’t exist and do nothing if it does exist.</p><p>You can run this playbook using the ansible-playbook command</p><pre>ansible-playbook file-name.yml -i &lt;inventory-file-path&gt; --private-key=&lt;private-key-path&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aElJpvxVeGnLssrs" /></figure><p>Verify that the file has been created at the specified location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*8ZJg_OWEoJSTDcu5" /></figure><p>Verify that the file has been created on different servers</p><pre>ansible all -a &quot;ls /home/ubuntu&quot; -i &lt;inventory-file&gt; --private-key=&lt;key-path&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t6sWhGxmV7AxRm4O" /></figure><h3>2.Write an ansible playbook to create a new user.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6LKwv0JSkzLF8U2D" /></figure><p>In this playbook, we define a single task that uses the user module to create the new user.</p><p>Run playbook using the ansible-playbook command,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3f_3neanvR-JUhAR" /></figure><p>To check if the user has been created, look for the user’s name in the /etc/passwd file.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YBTs-fD1_5I4XYd1" /></figure><h3>3. Write an ansible playbook to install docker on a group of servers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M6U8Qo_HpRmTC2Qj" /></figure><p>In this playbook, we define three tasks that install Docker on a group of servers. The hosts parameter specifies the group of servers where Docker will be installed. The become parameter is set to yes, which means that the tasks will use elevated privileges to install Docker.</p><p>The first task adds the Docker GPG key to the apt keyring, which is required for package signature verification.</p><p>The second task adds the Docker repository to the list of sources used by apt-get. This allows the system to download Docker packages from the Docker repository.</p><p>The final task installs Docker using the apt module. We specify the package name as docker-ce, which installs the Community Edition of Docker.</p><p>Run this playbook using the ansible-playbook command,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7_vVEtVEoAlds0si" /></figure><p>Verify that Docker has been installed on multiple servers.</p><pre>ansible all -a &quot;docker --version&quot; -i &lt;inventory-path&gt; --private-key=&lt;key-path&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sQ7DeoBb6X44yeem" /></figure><h3>Task-02</h3><h3>Write a blog about writing ansible playbooks with the best practices.</h3><p>Ansible is a powerful open-source automation tool that allows you to automate IT infrastructure management. Ansible playbooks are the configuration files that describe the desired state of your systems. Writing Ansible playbooks with best practices can make your automation more robust, reliable, and scalable. In this blog, we will discuss some best practices for writing Ansible playbooks.</p><p>Use a clear structure:</p><p>Make sure your playbook is organized and easy to read. Use comments and section headers to explain what each part of the playbook does. Avoid nesting too many tasks or plays inside each other, as it can make the playbook difficult to read and maintain.</p><p>Use idempotent tasks:</p><p>Idempotency is one of the key principles of Ansible. It means that a task should be designed in such a way that it can be executed repeatedly without changing the state of the system. This makes your playbook more robust and prevents unexpected changes to the system. You can achieve idempotency by using modules that are designed to be idempotent, such as apt, yum, and copy.</p><p>Example:</p><pre>- name: Install Apache web server<br>  apt:<br>    name: apache2<br>    state: latest</pre><p>In this example, the apt module will only install the Apache web server if it is not already installed or if there is a newer version available.</p><p>Use variables:</p><p>Variables can make your playbook more flexible and reusable. They allow you to store values that can be used across multiple tasks and playbooks. You can define variables in the playbook itself or in separate files, such as group_vars or host_vars.</p><p>Example:</p><pre>- name: Install Nginx web server<br>  apt:<br>    name: nginx<br>    state: latest</pre><pre>- name: Configure Nginx web server<br>  template:<br>    src: nginx.conf.j2<br>    dest: /etc/nginx/nginx.conf<br>  vars:<br>    nginx_port: 80</pre><p>In this example, we are using a variable nginx_port to define the port number used by Nginx. The variable is defined in the vars section of the template task.</p><p>Use roles:</p><p>Roles are a way to organize your tasks, variables, and files into reusable components. They can be used across multiple playbooks and provide a way to share functionality between different teams. Roles can also make your playbook more modular and easier to maintain.</p><p>Example:</p><pre>- name: Install web serve<br>  hosts: all<br>  roles:<br>    - webserver</pre><p>In this example, we are using a role called webserver to install the web server on the all group of hosts.</p><p>Use tags:</p><p>Tags allow you to selectively run specific tasks or groups of tasks within a playbook. This can be useful when testing or debugging your playbook or when you need to run a subset of tasks. Tags can be added to individual tasks or to entire plays.</p><p>Example:</p><pre>- name: Install web serve<br>  hosts: all<br>  become: yes<br>  tags:<br>    - webserver<br></pre><pre>  tasks:<br>    - name: Install Apache web server<br>      apt:<br>        name: apache2<br>        state: latest<br>      tags:<br>        - apache<br></pre><pre>    - name: Install Nginx web server<br>      apt:<br>        name: nginx<br>        state: latest<br>      tags:<br>        - nginx</pre><p>In this example, we are using tags to selectively run the Apache or Nginx installation tasks.</p><p>Use conditionals:</p><p>Conditionals allow you to execute a task only if a specific condition is met. This can be useful when you need to run a task only on a subset of hosts or when you need to run a task only if a specific variable is defined.</p><p>Example:</p><pre>---<br>- name: Example playbook with a conditional<br>  hosts: all<br>  vars:<br>    myvar: &quot;foo&quot;<br>  tasks:<br>    - name: Task 1<br>      debug:<br>        msg: &quot;This task will always run&quot;</pre><pre>    - name: Task 2<br>      debug:<br>        msg: &quot;This task will run if myvar equals &#39;foo&#39;&quot;<br>      when: myvar == &quot;foo&quot;</pre><p>In this example, the playbook has two tasks. Task 1 will always run because it doesn’t have a conditional attached to it. Task 2 will only run if the variable myvar is equal to “foo”. If myvar has any other value, Task 2 will be skipped.</p><p>By following these best practices, you can write efficient, modular, and maintainable Ansible playbooks that can be easily adapted to different environments and situations.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0bf9336a6e19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Ad-hoc commands in Ansible]]></title>
            <link>https://medium.com/@sayalishewale12/understanding-ad-hoc-commands-in-ansible-f8c8f7fa8d38?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8c8f7fa8d38</guid>
            <category><![CDATA[configuration-management]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 11:32:22 GMT</pubDate>
            <atom:updated>2023-09-25T11:32:22.577Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible ad hoc commands are one-liners designed to achieve a very specific task they are like quick snippets and your compact Swiss army knife when you want to do a quick task across multiple machines.</p><p>To put simply, Ansible ad hoc commands are one-liner Linux shell commands and playbooks are like a shell script, a collective of many commands with logic.</p><p>Ansible ad hoc commands come in handy when you want to perform a quick task.</p><h3>Task-01</h3><p><strong>1.Write an ansible ad hoc ping command to ping 3 servers from inventory file</strong></p><pre>ansible -i /path/to/inventory/file server1:server2:server3 -m ping</pre><p>This command uses the ansible command with the following options:</p><ul><li>-i /path/to/inventory/file: specifies the path to the inventory file containing the servers we want to ping. /etc/ansible/hosts is by default path of the inventory file. there is no need to write a path in an ansible ad hoc command. If your inventory file is at different location then you need to write the path of inventory file in ad hoc command.</li><li>server1:server2:server3: specifies the list of servers to ping, separated by colons.</li><li>-m ping: specifies that we want to use the ping module to ping the servers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-rXvau4tr_UR8qsS" /></figure><p><strong>2.</strong> <strong>Write an ansible ad hoc command to check uptime</strong></p><pre>ansible -i /path/to/inventory/file all -m command -a uptime</pre><p>This command uses the ansible command with the following options:</p><ul><li>-m command: specifies that we want to use the command module to execute the uptime command on the remote servers.</li><li>-a uptime: specifies the arguments to pass to the command module, which in this case is simply the uptime command.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uqldhHPiebceeIHX" /></figure><p><strong>3. ansible ad hoc command to check the free memory or memory usage of hosts</strong></p><pre>ansible -i /path/to/inventory/file all -a &quot;free -m&quot;</pre><p>-a “free -m”: the -a option specifies the arguments to pass to the command to be executed on the remote hosts. In this case, the free -m command is executed to show the memory usage on each host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kDOd_dASqGl32XzI" /></figure><p><strong>4. ansible ad hoc command to get physical memory allocated to the host</strong></p><pre>ansible all -m shell -a &quot;cat /proc/meminfo|head -2&quot;</pre><ul><li>-m shell: the -m option specifies the module to use to execute the command on the remote hosts. In this case, the shell module is used to execute the command.</li><li>-a “cat /proc/meminfo|head -2”: the -a option specifies the arguments to pass to the module to execute the command on the remote hosts. In this case, the cat /proc/meminfo|head -2 command is executed to display the first two lines of the /proc/meminfo file on each host.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qsfg6CqMkG8sCCNg" /></figure><p><strong>5</strong>.<strong>To check the disk space on all hosts in an inventory file</strong></p><pre>ansible -i inventory_file all -m shell -a &#39;df -h&#39;</pre><p>This command uses the df command to show the disk space usage on each host in the inventory file.</p><p>The -m shell option is used to execute the command on the remote hosts using the shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oerGwO0iE9Kil0W8" /></figure><p><strong>6. To list all the running processes on a specific host in an inventory file</strong></p><pre>ansible -i inventory_file specific_host -m command -a &#39;ps aux&#39;</pre><p>This command uses the ps command to list all the running processes on the specific host in the inventory file. The -m command option is used to execute the command on the remote hosts using the command module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J6vD2JsVd2r3kZSr" /></figure><p><strong>7. To run a shell command with sudo on all hosts in an inventory file</strong></p><pre>ansible -i inventory_file all -b -m shell -a &#39;sudo-command&#39;</pre><p>This command uses the -b option to become the sudo user before executing the command with the shell module. Replace command with the command you want to run as sudo.</p><ol><li>Use sudo command ‘sudo apt-get install docker.io -y’, so by using this ad hoc command you can install jenkins, nginx, apache, nodejs etc. on your 3 or more servers.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*peb7DDV9NVIuntAw" /></figure><p>Check docker is install or not in all the 3 servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A8liqN_oz_pPDHjY" /></figure><p>2. Use sudo command ‘sudo git — version’ which shows all 3 servers git version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GvLeQjK1UIn_pnpO" /></figure><p>3. Use sudo command ‘sudo python — version’ which shows all 3 server python version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9ZTi8qHyJ-dXeotB" /></figure><p><strong>8.To check the status of a specific service on all hosts in an inventory file</strong></p><pre>ansible -i inventory_file all -m service -a &#39;name=apache2 state=started&#39;</pre><p>This command uses the service module to check the status of the apache2 service on all hosts in the inventory file. The -a ‘name=apache2 state=started’ option specifies the name of the service to check and the desired state, which is started in this case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y58XMrE1cBfTqHu4" /></figure><p>You can check the status of a specific service on single hosts or server1</p><pre>ansible -i inventory_file server1 -m service -a &#39;name=apache2 state=started&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l_Cea4gOdBNWPqJx" /></figure><p><strong>9. To copy a file to all hosts in an inventory file</strong></p><pre>ansible -i inventory_file all -m copy -a &#39;src=/local/path/to/file dest=/remote/path/to/file mode=0644&#39;</pre><p>This command uses the copy module to copy a file from the local machine to all hosts in the inventory file. The -a ‘src=/local/path/to/file dest=/remote/path/to/file mode=0644’ option specifies the source and destination paths for the file, as well as the desired file permissions.</p><p>first create a simple text file at any location, here create a text file at /home/ubuntu location with name demo.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vUK2TWMIrNt3bPPv" /></figure><p>Check file is successfully copied to all the servers using ‘sudo ls command’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WzZJLrEEvulhRdd8" /></figure><p><strong>10. Create a Directory with 755 permission using ansible ad hoc command</strong></p><pre>ansible all -m file -a &quot;path=/home/ubuntu/ansible state=directory mode=0755&quot; -b</pre><ul><li>-a “path=/home/ubuntu/ansible state=directory mode=0755”: This is the argument to the -m option. It tells Ansible to create a directory at the path /home/ubuntu/ansible with the directory state (i.e., to create a directory if it doesn’t exist). The mode argument sets the file permissions to 0755, which means that the owner has read, write, and execute permissions, and everyone else has read and execute permissions.</li><li>-b: This tells Ansible to run the command as the superuser (i.e., with sudo).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XlLsjmLq_aOqKP0M" /></figure><p><strong>11. Create a file with 755 permission using ansible ad hoc commands</strong></p><pre>ansible all -m file -a &quot;path=/path/to/file state=touch mode=0755&quot;</pre><ul><li>-a “path=/path/to/file state=touch mode=0755”: This is the argument to the -m option. It tells Ansible to create a file at the path /path-to-file with the touch state (i.e., to create the file if it doesn’t exist). The mode argument sets the file permissions to 0755, which means that the owner has read, write, and execute permissions, and everyone else has read and execute permissions.</li><li>-b: This tells Ansible to run the command as the superuser (i.e., with sudo).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pmoILqJC-c1nKQtx" /></figure><p>Check file is created with given permissions using sudo ls -l command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_IH359JBVQzqbZP0" /></figure><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8c8f7fa8d38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Configuration Management with Ansible]]></title>
            <link>https://medium.com/@sayalishewale12/understanding-configuration-management-with-ansible-a551172e96e4?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/a551172e96e4</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[configuration-management]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 05:28:08 GMT</pubDate>
            <atom:updated>2023-09-21T05:28:08.823Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Ansible?</h3><p>Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intra-service orchestration, and provisioning.</p><h3>Task-01</h3><p>Installation of Ansible on AWS EC2 (Master Node)</p><p><strong>sudo apt-add-repository ppa: ansible/ansible</strong></p><p><strong>sudo apt update</strong></p><p><strong>sudo apt install ansible</strong></p><p>Create an EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JvqqlMg5R4MGXcXx" /></figure><p>Connect to your EC2 instance using SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GK1u2d2OoopO-CVg" /></figure><p>Add the Ansible PPA repository using the following command:</p><pre>sudo apt-add-repository ppa:ansible/ansible</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KjrgSEQuh2Q_Slkb" /></figure><p>Update the package using following commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j5rAppjvk3JqpzSl" /></figure><p>Install Ansible using the following command:</p><pre>sudo apt install ansible</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MtcVjCRvbIQucw4e" /></figure><p>Once the installation is complete, you can check the version of Ansible using the following command:</p><pre>ansible --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GY2IpvcQz_5NhRZ3" /></figure><h3>Task-02</h3><p>Read more about Hosts file sudo nano /etc/ansible/hosts and ansible-inventory — list -y</p><p>The Ansible hosts file is a configuration file that contains a list of hosts or servers that Ansible can manage. The hosts file is located at /etc/ansible/hosts on the Ansible control node, and it is used to define the inventory of hosts that Ansible can manage.</p><p>To edit the hosts file, you can use any text editor of your choice.</p><pre>sudo nano /etc/ansible/hosts</pre><p>Once the file is open, you can add the IP addresses or hostnames of the servers you want to manage. The format for adding hosts is as follows:</p><pre>[group_name] <br>host1 <br>host2 <br>host3</pre><p>In this example, group_name is a user-defined name for the group of hosts, and host1, host2, and host3 are the IP addresses or hostnames of the servers. You can define multiple groups of hosts in the hosts file, each with its own list of hosts.</p><p>After you have added the hosts to the file, you can verify the inventory of hosts that Ansible can manage using the ansible-inventory command with the — list and -y options:</p><pre>ansible-inventory --list -y</pre><p>This command will display a YAML-formatted list of hosts and their attributes, including the hostnames, IP addresses, and any other defined variables or group memberships.</p><h3>Task-03</h3><p>Setup 2 more EC2 instances with same Private keys as the previous instance (Node)</p><p>Launch 2 new EC2 instances with same private keys as ansible-demo-master instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tYNr3Tluji3cc1Vd" /></figure><p>Copy the private key to master server where Ansible is setup.</p><p>Copy private key from your local.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UtUB-aifsdS9YGZx" /></figure><p>In master server where ansible is setup, create a new file at location /home/ubuntu/.ssh and paste private key to that file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GRH2CubXmAb6FktI" /></figure><p>Give permissions to the key file using chmod command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*Fof8manqX9wNX407" /></figure><p>Create an inventory file for Ansible that lists the IP addresses of the two new EC2 instances, and specifies the private key file to use for authentication.</p><p>Create inventory file at location /etc/ansible/hosts which is by default location of file. Ansible hosts file is a configuration file that contains a list of hosts or servers.</p><p>Once the file is open, you can add the IP addresses of the servers also add private key file location to use for authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zVZbct60WvRHhC-H" /></figure><p>After you have added the hosts to the file, you can verify the inventory of hosts that Ansible can manage using the ansible-inventory command.</p><pre>ansible-inventory --list -y</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*khpTHI3b0Ij1dokU" /></figure><p>Try a ping command using ansible to the Nodes.</p><p>To test that Ansible is able to connect to your nodes, you can use the following command:</p><pre>ansible all -m ping</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/0*ygyjpeAKK-Vv-zFc" /></figure><p>The ping module will test if you have valid credentials for connecting to the nodes defined in your inventory file. A pong reply back means Ansible is ready to run commands on that node.</p><p>You can also use servers instead of all which is a group name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9GSDiiErRbLEtgxZ" /></figure><p>Thank you for reading article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a551172e96e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Infrastructure as Code and Configuration Management]]></title>
            <link>https://medium.com/@sayalishewale12/understanding-infrastructure-as-code-and-configuration-management-b219989f76f6?source=rss-d240e17bfeda------2</link>
            <guid isPermaLink="false">https://medium.com/p/b219989f76f6</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[configuration-management]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Sayali Shewale]]></dc:creator>
            <pubDate>Wed, 20 Sep 2023 06:42:07 GMT</pubDate>
            <atom:updated>2023-09-20T06:42:07.612Z</atom:updated>
            <content:encoded><![CDATA[<h3>What’s the difference?</h3><p>When it comes to the cloud, Infrastructure as Code (IaC) and Configuration Management (CM) are inseparable. With IaC, a descriptive model is used for infrastructure management. To name a few examples of infrastructure: networks, virtual computers, and load balancers. Using an IaC model always results in the same setting.</p><p>Throughout the lifecycle of a product, Configuration Management (CM) ensures that the performance, functional and physical inputs, requirements, design, and operations of that product remain consistent.</p><h3>Task-01</h3><p><strong>1.Read more about IaC and Config. Management Tools</strong></p><p>IaC manages infrastructure using a descriptive model. Infrastructure includes networks, virtual machines, load balancers, to name a few. An IaC model produces the same environment every time it is applied.</p><p>Configuration Management (CM) maintains the consistency of an application’s performance, as well as its functional and physical inputs along with requirements, overall design, and operations throughout the lifespan of the product.</p><p><strong>2. Give differences on both with suitable examples</strong></p><p>The main difference between Infrastructure as Code (IaC) and Configuration Management (CM) is that IaC focuses on managing and provisioning infrastructure through code, while CM focuses on automating the configuration and management of software applications, operating systems, and servers.</p><p><strong>Infrastructure as Code (IaC)</strong> is a practice of managing and provisioning IT infrastructure through code. IaC allows teams to manage infrastructure in a repeatable, scalable, and automated manner. With IaC, infrastructure components such as virtual machines, networks, and storage can be defined as code, which can be version controlled, tested, and deployed like any other codebase.</p><p><strong>Configuration Management (CM)</strong>, on the other hand, is the practice of automating the configuration and management of software applications, operating systems, and servers. CM tools help teams automate the installation and configuration of software packages, enforce security policies, and manage system settings.</p><p>While IaC focuses on the infrastructure layer, CM focuses on the application layer. However, both concepts work together to help teams automate and manage their IT infrastructure more efficiently.</p><p>3.What are most common IaC and Config management Tools?</p><p>Some common Infrastructure as code tools include:</p><p><strong>Terraform</strong> — A tool for building, changing, and versioning infrastructure safely and efficiently.</p><p><strong>CloudFormation</strong> — A service provided by AWS for defining infrastructure as code in AWS.</p><p><strong>Pulumi </strong>— A tool for creating, deploying, and managing infrastructure on any cloud using your favorite languages.</p><p>Some common Configuration Management tools include:</p><p><strong>Chef </strong>— A configuration management tool that automates the deployment, configuration, and management of software.</p><p><strong>Puppet</strong> — A configuration management tool that helps automate the management of infrastructure, applications, and compliance.</p><p><strong>SaltStack</strong> — A tool that automates the configuration and management of software applications, operating systems, and servers.</p><p><strong>Ansible</strong> — A popular configuration management tool that can also be used for infrastructure automation. Ansible uses a declarative language to define infrastructure, making it easy to read and understand. Ansible can be used to manage both on-premise and cloud infrastructure.</p><p>IaC and CM are complementary concepts that help teams automate and manage their IT infrastructure more efficiently. While IaC focuses on the infrastructure layer, CM focuses on the application layer. Some common IaC tools include Terraform, CloudFormation, Ansible, and Pulumi, while common CM tools include Chef, Puppet, SaltStack, and Ansible.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b219989f76f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>