<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>The Ops Community ⚙️: kingsathurthi</title>
    <description>The latest articles on The Ops Community ⚙️ by kingsathurthi (@kingsathurthi).</description>
    <link>https://community.ops.io/kingsathurthi</link>
    <image>
      <url>https://community.ops.io/images/2KC4AdpkUVkmOcvGxawT4LTyY15nqRz8SbcJAS_GrRI/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL3Vz/ZXIvcHJvZmlsZV9p/bWFnZS8xOTQvMDkx/YmY4ZDMtYWUyZi00/ODMzLWFhNjUtMmJl/OTJmOWYwMDZkLmpw/Zw</url>
      <title>The Ops Community ⚙️: kingsathurthi</title>
      <link>https://community.ops.io/kingsathurthi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ops.io/feed/kingsathurthi"/>
    <language>en</language>
    <item>
      <title>Pulumi Challenge! Quickstart Guide</title>
      <dc:creator>kingsathurthi</dc:creator>
      <pubDate>Fri, 14 Oct 2022 14:28:31 +0000</pubDate>
      <link>https://community.ops.io/kingsathurthi/pulumi-challenge-quickstart-guide-cj6</link>
      <guid>https://community.ops.io/kingsathurthi/pulumi-challenge-quickstart-guide-cj6</guid>
      <description>&lt;h2&gt;
  
  
  What is Pulumi?
&lt;/h2&gt;

&lt;p&gt;Pulumi is a universal infrastructure as code platform that allows you to use familiar programming languages and tools to build, deploy, and manage cloud infrastructure. Pulumi is free, open source, and optionally pairs with the Pulumi Service to make managing infrastructure secure, reliable, and hassle-free. Currently Pulumi is running some challenge contest lets try out what it is. you can find the complete information in this official &lt;a href="https://www.pulumi.com/challenge/one-quickstart/"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quickstart
&lt;/h2&gt;

&lt;p&gt;Pulumi Architecture Templates make it quick and easy to get started with a wide variety of clouds, tools, and technologies when you want to try something new but don't want to write boilerplate yourself. It's a great way to get started with Pulumi quickly, no matter what you need to build. Try it for yourself with serverless AWS templates and win some swag in the process!&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://app.pulumi.com/signup?_gl=1*1roxz6e*_ga*MTIyMDY0OTEyOC4xNjY1NzQ4ODU4*_ga_FQHG5CVY2D*MTY2NTc0ODg1OC4xLjEuMTY2NTc0ODg3Ni40Mi4wLjA."&gt;Pulumi account&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.pulumi.com/docs/get-started/install/"&gt;Pulumi CLI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.python.org/downloads/"&gt;Python 3.9 or higher&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/"&gt;AWS account&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"&gt;AWS CLI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this demo I'm going to create new Amazon EC2 Instance and install all the required prerequisites components. you can use own device to do this&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - Creating Pulumi Architecture Templates
&lt;/h2&gt;

&lt;p&gt;you will see how to create new Pulumi Architecture Templates, specifically for serverless blueprints for AWS with the language of your choice. but here we are gonna use Python&lt;/p&gt;

&lt;p&gt;let's create new directory named &lt;code&gt;quickstart-challenge&lt;/code&gt; and change directory into it using below commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`mkdir quickstart-challenge &amp;amp;&amp;amp; cd quickstart-challenge`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/YnL_DLxHtu3WDyqEVwR5IsqW3OmW3m11ED2jJgfRC5Y/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3JwYjJv/cjJ5cjJvemh2ZWhq/cnZnLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/YnL_DLxHtu3WDyqEVwR5IsqW3OmW3m11ED2jJgfRC5Y/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3JwYjJv/cjJ5cjJvemh2ZWhq/cnZnLnBuZw" alt="1" width="880" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After creating the directory let's create pulumi Architecture Templates using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi new serverless-aws-python 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/5QrjbZd3gURi5jHEoY2uxkqgkrVLtBPDwpjlEKbdvKM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL201MzR1/ZW14bHg1N3dsdXRv/djU0LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/5QrjbZd3gURi5jHEoY2uxkqgkrVLtBPDwpjlEKbdvKM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL201MzR1/ZW14bHg1N3dsdXRv/djU0LnBuZw" alt="2" width="880" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you ran the above command it will ask for access token please login to your pulumi account and create token and save it safely.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/y9uezaICoyApGlVKAptCz3p0saAdxrE6zSV6YLg3Qug/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2t3Z3Fy/YWZvcnJmYmw0OGtw/ZmF2LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/y9uezaICoyApGlVKAptCz3p0saAdxrE6zSV6YLg3Qug/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2t3Z3Fy/YWZvcnJmYmw0OGtw/ZmF2LnBuZw" alt="3" width="880" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy and paste the token and continue the project and stack setup like below in the screenshot. leave input blank so that it can take default value.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Must use AWS region us-west-2&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/t9p7bl6VJpSjKAQrMxhpQ0-FKT_8dWCOrRYozHolYTs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzBtd2w5/eDZtYmtrYnhjdXR3/cmExLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/t9p7bl6VJpSjKAQrMxhpQ0-FKT_8dWCOrRYozHolYTs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzBtd2w5/eDZtYmtrYnhjdXR3/cmExLnBuZw" alt="4" width="880" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2. Exploring Blueprints
&lt;/h2&gt;

&lt;p&gt;let explore the Pulumi architectural blueprints before that configure AWS CLI by running below command and enter your aws account access key ID and secret access key and region.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;aws configure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/nDEp-UsXRsO6Y6RV-caIySjhyKKSuLTCHYegfqO-2io/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzBleDgz/bm5vbDdsdjBreXBm/dHBnLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/nDEp-UsXRsO6Y6RV-caIySjhyKKSuLTCHYegfqO-2io/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzBleDgz/bm5vbDdsdjBreXBm/dHBnLnBuZw" alt="5" width="818" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now run below command command see the blueprint in the screen shot&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi preview
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/TlZhfXempgYvZ3_KBQ8RkcZ-Bmz6Wl9G0uhSvRJGcTQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL213cTFl/amZ1d2Jkcmc0d2tk/ZW4wLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/TlZhfXempgYvZ3_KBQ8RkcZ-Bmz6Wl9G0uhSvRJGcTQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL213cTFl/amZ1d2Jkcmc0d2tk/ZW4wLnBuZw" alt="6" width="880" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you see the output for the &lt;code&gt;pulumi preview&lt;/code&gt; command it create the IAM role, Lambda Function, S3 Bucket, API gateway under the hood.&lt;/p&gt;

&lt;p&gt;Step 3. Creating Policy Packs&lt;/p&gt;

&lt;p&gt;When you’re using Python or Typescript, Pulumi allows you to enforce gated deployments with Policy Packs, which can be used locally with the free tier. These are a set of rules, expressed programmatically, that are executed against the resources being deployed. Any violation of those rules will block the deployment. Usually, Policy Packs are used to enforce security or cost optimization rules, but in this case we’re going to use one to interact with pulumi's swag provider.&lt;/p&gt;

&lt;p&gt;Within your existing Pulumi program, create a new directory for your Policy Pack and navigate into it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir policy &amp;amp;&amp;amp; cd policy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating policy pack using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi policy new aws-python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run the command it will execute and crate the respective policy like below &lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/L6JfKoPGPJZR2SJOPHJhsAVwR7BkjZ7P25WmMfYEPPI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzRuZnZh/N2R6Z2MxZnhqaDFn/ODM3LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/L6JfKoPGPJZR2SJOPHJhsAVwR7BkjZ7P25WmMfYEPPI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzRuZnZh/N2R6Z2MxZnhqaDFn/ODM3LnBuZw" alt="7" width="880" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The default Policy Pack prevents developers from allowing public read access on an AWS S3 bucket but that isn’t what we need here. Replace the contents of the new &lt;strong&gt;main&lt;/strong&gt;.py in the directory &lt;code&gt;/home/ec2-user/quickstart-challenge/policy&lt;/code&gt; with the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
from pulumi_policy import (
    EnforcementLevel,
    PolicyPack,
    ReportViolation,
    ResourceValidationArgs,
    ResourceValidationPolicy,
    PolicyConfigSchema
)


def map_swag_to_form(swag_var):
    data_json = {
        'usp': 'pp_url'
    }
    swag = swag_var
    data_json['entry.1720843992'] = swag['name']
    data_json['entry.511943887'] = swag['email']
    data_json['entry.1289952319'] = swag['address']
    data_json['entry.1240089905'] = swag['size']
    return data_json


def pulumi_swag_not_submitted(args: ResourceValidationArgs, report_violation: ReportViolation):
    if not args.resource_type == "pulumi:pulumi:Stack":
        return
    swag = args.get_config()
    data_dict = map_swag_to_form(swag)
    print(data_dict)
    headers = {
        "Referer": "https://docs.google.com/forms/d/e/1FAIpQLSfBr2f6rhXYbMXi8Caftu-zWtNPRDoWUEukrTJKuwO3OyYRvg/viewform",
        "User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36"
    }
    response = requests.post(
        url="https://docs.google.com/forms/d/e/1FAIpQLSfBr2f6rhXYbMXi8Caftu-zWtNPRDoWUEukrTJKuwO3OyYRvg/formResponse",
        headers=headers,
        data=data_dict
    )
    print(response.status_code)


submit_swag = ResourceValidationPolicy(
    name="pulumi-challenge-swag",
    description="stuff",
    validate=pulumi_swag_not_submitted,
    config_schema=PolicyConfigSchema(
        properties={
            "name": {
                "type": "string",
                "minLength": 2
            },
            "email": {
                "type": "string",
                "minLength": 6,
                "format": "email"
            },
            "address": {
                "type": "string",
                "minLength": 2
            },
            "size": {
                "type": "string",
                "minLength": 1,
                "enum": [
                    "XS",
                    "S",
                    "M",
                    "L",
                    "XL"
                ]
            }
        },
        required=[
            "name",
            "email",
            "address",
            "size"
        ]
    )
)

PolicyPack(
    name="aws-python",
    enforcement_level=EnforcementLevel.MANDATORY,
    policies=[
        submit_swag
    ],
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4. Complying with Policies
&lt;/h2&gt;

&lt;p&gt;The Policy Pack we’ve defined requires that your Pulumi program involve a JSON file containing specific data. In order to comply with it and get swag, we need to create this file.&lt;/p&gt;

&lt;p&gt;Navigate one directory up, back into your main Pulumi Challenge directory. Create a new file called &lt;code&gt;swag.json&lt;/code&gt; in the directory &lt;code&gt;/home/ec2-user/quickstart-challenge/&lt;/code&gt; , and add the following (replacing the values with your own information)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "pulumi-challenge-swag": {
    "name": "&amp;lt;your name&amp;gt;",
    "email": "&amp;lt;your email&amp;gt;",
    "address": "&amp;lt;your address&amp;gt;",
    "size": "&amp;lt;one of XS, S, M, L, XL&amp;gt;"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also have new dependencies to add to requirements.txt at the root of project directory. Replace with below value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi&amp;gt;=3.0.0,&amp;lt;4.0.0
pulumi-aws&amp;gt;=5.10.0,&amp;lt;6.0.0
pulumi-aws-apigateway&amp;gt;=0.0.11
pulumi-awsx==1.0.0-beta.9
pulumi-policy&amp;gt;=1.3.0,&amp;lt;2.0.0
requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once updated the requirements.txt run the below pip install command in the virtual environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source venv/bin/activate
pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/iH1Jnu8_5ZWRmD3YivHb8ohK1Rt8SwvfBNpk3sMHrVs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzQ3dm9q/OXI5cDZqZm9pMnA2/anB4LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/iH1Jnu8_5ZWRmD3YivHb8ohK1Rt8SwvfBNpk3sMHrVs/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzQ3dm9q/OXI5cDZqZm9pMnA2/anB4LnBuZw" alt="8" width="880" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Execute your policy pack against your Pulumi Program with the following command at the root of your project to submit for your swag&lt;/p&gt;

&lt;p&gt;use below command to preview the blueprint&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi preview --policy-pack policy --policy-pack-config swag.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/6HsNBV7WSt3mYguB46c-n3DOstO8QR3hO7OlpGTU5DQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2V4emFi/bWtiNnRwcDB2c3hs/c200LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/6HsNBV7WSt3mYguB46c-n3DOstO8QR3hO7OlpGTU5DQ/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2V4emFi/bWtiNnRwcDB2c3hs/c200LnBuZw" alt="9" width="880" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you run the preview command and get 200 http code status that everything did is correct. Now lets run the below command to deploy the application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi up --policy-pack policy --policy-pack-config swag.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/TuwqXNXRQPwhrd0qNKe6HwTaLBuDpNJ25CQom3z_chc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2o4bmlk/dWxkeWhieTU3a2Nv/Mnh3LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/TuwqXNXRQPwhrd0qNKe6HwTaLBuDpNJ25CQom3z_chc/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2o4bmlk/dWxkeWhieTU3a2Nv/Mnh3LnBuZw" alt="10" width="880" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;give yes and proceed to the deployment. once the deployment is completed you will see the output grab the application URL and visit&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/GLnCNtR9drh_37CEyhNGihLRC-Kga3U2cDKbpeVR3QE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2tqMWZ3/MGtvYmNjOTd1ZXBq/ZjkwLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/GLnCNtR9drh_37CEyhNGihLRC-Kga3U2cDKbpeVR3QE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2tqMWZ3/MGtvYmNjOTd1ZXBq/ZjkwLnBuZw" alt="11" width="878" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below the application deployed using Pulumi architectural template&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/kBQKfCprFp6W50_21_KgY5Nsw_zQdF1OHr0GyoicXuE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzFkcGV2/ZGZmaWVja2dkamFp/bWkzLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/kBQKfCprFp6W50_21_KgY5Nsw_zQdF1OHr0GyoicXuE/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzFkcGV2/ZGZmaWVja2dkamFp/bWkzLnBuZw" alt="12" width="880" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! You completed the Pulumi Challenge. finally destroy the the environment and stack. using below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pulumi destroy -y
pulumi stack rm dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading the post I hope you enjoyed the Pulumi challenge.&lt;/p&gt;

</description>
      <category>pulumi</category>
      <category>lambda</category>
      <category>iac</category>
      <category>devops</category>
    </item>
    <item>
      <title>Docker Cheat sheet</title>
      <dc:creator>kingsathurthi</dc:creator>
      <pubDate>Sat, 28 May 2022 18:04:04 +0000</pubDate>
      <link>https://community.ops.io/kingsathurthi/docker-cheat-sheet-3e0g</link>
      <guid>https://community.ops.io/kingsathurthi/docker-cheat-sheet-3e0g</guid>
      <description>&lt;p&gt;Hi folks in this post we will see some important docker commands to manage docker image and containers&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Process Management&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Show all running docker containers&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show all docker containers&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Run a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run &amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Run a container and connect to it&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it &amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Run a container in the background&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d &amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Stop a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stop &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Kill a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker kill &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove the stopped container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Docker rm &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Images/Repository&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;List available local images&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove docker image&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rmi &amp;lt;image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Search for docker images&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker search &amp;lt;image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pull a docker image&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull &amp;lt;image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Build an image with a dockerfile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t &amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt; &amp;lt;run_directory&amp;gt; -f
&amp;lt;dockerfile&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Login to a remote repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker login &amp;lt;repository&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Push an image to your remote repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker push &amp;lt;image&amp;gt;:&amp;lt;tag&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show metadata for an image&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image inspect &amp;lt;image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove all unused docker images&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Docker Compose&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Start your docker-compose defined resources in detached mode&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d -f &amp;lt;docker_compose_yaml&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Stop all docker-compose resources&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Destroy all docker-compose resources&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose down 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show docker-compose processes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show docker-compose logs&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose logs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show docker-compose resource consumption&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose top
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pull latest docker-compose images&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Volumes &amp;amp; Ports&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;List volumes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a volume&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume create &amp;lt;volume&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Delete a volume&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume rm &amp;lt;volume&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show volume metadata&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume inspect &amp;lt;volume&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Delete all volumes not attached to a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Mount a local directory to your container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -v &amp;lt;local_dir&amp;gt;:&amp;lt;container_dir&amp;gt; &amp;lt;image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Copy file or folder from a docker container to host machine&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker cp &amp;lt;container&amp;gt;:&amp;lt;container_dir&amp;gt; &amp;lt;local_dir&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Copy file or folder from local machine onto a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker cp &amp;lt;local_dir&amp;gt; &amp;lt;container&amp;gt;:&amp;lt;container_dir&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Map a local port to a docker instance&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d -p &amp;lt;local_port&amp;gt;:&amp;lt;docker_port&amp;gt; &amp;lt;image&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;List the ports a docker container is running on&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker port &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Troubleshooting&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Show the logs of a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Follow/tail the logs of a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs -f &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show timestamps on docker logs&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs -t &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show details/metadata of a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker inspect &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show a 'top' view of processes running on a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker top &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show a 'top' view of all docker containers&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker stats
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show any files that have changed since startup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker diff &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Connect to an already running container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker attach &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Execute a command on a container&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec-it &amp;lt;container_id&amp;gt; /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show docker system wide information&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker system info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Show docker disk space used&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker system df
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove build cache&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker builder prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Deploy Angular web app in remote server using Ansible</title>
      <dc:creator>kingsathurthi</dc:creator>
      <pubDate>Fri, 27 May 2022 18:23:38 +0000</pubDate>
      <link>https://community.ops.io/kingsathurthi/deploy-angular-web-app-in-remote-server-using-ansible-4225</link>
      <guid>https://community.ops.io/kingsathurthi/deploy-angular-web-app-in-remote-server-using-ansible-4225</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this article we are going to see how we are going to leverage Ansible to deploy Angular web app in remote server. Ansible is an open-source IT automation tool that automates provisioning, configuration management, application deployment, orchestration, and many other manual IT processes and Angular is a platform and framework for building single-page client applications using HTML and TypeScript. let's gets into the action&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Prerequisite&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ansible controller (Your PC or any other machine installed with Ansible)&lt;/li&gt;
&lt;li&gt;Remote Server (ex.AWS EC2)&lt;/li&gt;
&lt;li&gt;Angular github repository (use this sample &lt;a href="https://github.com/kingsathurthi/ops-ansible-angular-demo"&gt;repo&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Please find the Ansible installation link &lt;a href="https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#id22"&gt;here&lt;/a&gt;. And I assume you have installed Angular and Nginx installed in your remote server and ssh should allowed from Ansible controller at least. Im using Ubuntu desktop and AWS EC2 instance. &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Ansible configuration&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Once you have installed Ansible in you machine. Please follow the instruction to configure the Ansible inventory.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;code&gt;/etc/ansible&lt;/code&gt; directory and open &lt;code&gt;hosts&lt;/code&gt; file using vim &lt;code&gt;sudo vim hosts&lt;/code&gt; and add below inventory details.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;inventory_name&amp;gt; ansible_host=&amp;lt;IP or URL&amp;gt; ansible_ssh_user=&amp;lt;username&amp;gt; ansible_ssh_private_key_file=path_to_your_pem&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please find below image for you reference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/zrLhJw7BsDNJDo9cTRqHXo2luz3w-L7n3yOoLcYdInM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3pvYXBs/NmRqOTJ6bGJrYTh4/M3hiLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/zrLhJw7BsDNJDo9cTRqHXo2luz3w-L7n3yOoLcYdInM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3pvYXBs/NmRqOTJ6bGJrYTh4/M3hiLnBuZw" alt="Ansible host" width="880" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it we configured remote host/server in the Ansible Inventory&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Let's check the connectivity between Ansible controller and remote server&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;First Disable Host Key Checking using below mentioned command because If a host is reinstalled and has a different key in ‘known_hosts’, this will result in an error message until corrected&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Go to &lt;code&gt;/etc/ansible&lt;/code&gt; directory and open &lt;code&gt;ansible.cfg&lt;/code&gt; file using vim &lt;code&gt;sudo vim ansible.cfg&lt;/code&gt; and below configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[defaults]
host_key_checking = False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please check below image for your reference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/bAN3VLgslwtNZguyXE_ZiVwABuY2Gwmq5GagTHRpSSI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzN2M3dn/NGlsZmtsYTNla2J3/bnN6LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/bAN3VLgslwtNZguyXE_ZiVwABuY2Gwmq5GagTHRpSSI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzN2M3dn/NGlsZmtsYTNla2J3/bnN6LnBuZw" alt="Ansible cofig" width="880" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After disabling the host key checking lets check the connectivity using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible ansible-demo -m ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the response like below image which means you are able to succesfully connect to the remote server/host&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/6gQSlJOGYrW2mAYaUL-OdrBj_jsVeZPlAPuwyWNmJcM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3pnazZ4/ZG05eXJ3amtoeXk3/aXdvLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/6gQSlJOGYrW2mAYaUL-OdrBj_jsVeZPlAPuwyWNmJcM/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3pnazZ4/ZG05eXJ3amtoeXk3/aXdvLnBuZw" alt="Ansible ping" width="668" height="215"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Create Ansible-Playbook for angular deployment&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Create Ansible-playbook yaml file in your directory for deploying angular web app in the remote server using below playbook&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- hosts: ansible-demo
  gather_facts: true
  vars:
    user: "ubuntu"
    date: "{{ lookup('pipe','date +%d%m%Y') }}"
    app_name: ops-ansible-angular-demo
    home_dir: /home/ubuntu
    repo_dir: "{{home_dir}}/Libraries/{{app_name}}"
    repo_app_dir: "{{repo_dir}}"
    project_dir: "/var/www/html/"

    repo_url: https://github.com/kingsathurthi/ops-ansible-angular-demo.git
    branch: main

  tasks:
    - name: "Clone git repository - https://{{repo_url}} of {{branch}} branch/tag to {{repo_dir}}"
      git: repo={{repo_url}} dest={{ repo_dir }} version={{branch}} force=yes update=yes clone=yes
      register: repo_clone

    - name: "Install packages based on package.json"
      npm: path={{repo_app_dir}}

    - name: "Run build command"
      command: ng build
      args:
       chdir: "{{repo_app_dir}}"

    - name: "Archive compiled files - {{repo_app_dir}}/dist/{{app_name}}/* to "
      become: yes
      archive: path={{repo_app_dir}}/dist/{{app_name}}/* dest={{repo_app_dir}}/{{app_name}}.tar.gz format=gz

    - name: "Copy artifact - {{repo_app_dir}}/{{app_name}}.tar.gz to {{project_dir}} server"
      copy: src="{{repo_app_dir}}/{{app_name}}.tar.gz" dest="{{project_dir}}/{{app_name}}.tar.gz" remote_src=yes #owner=www-data group=www-data mode=0644
      become: yes
      become_user: root

    - name: "Extract archived files to {{project_dir}} path"
      become: true
      unarchive: src={{project_dir}}/{{app_name}}.tar.gz  dest={{project_dir}} remote_src=yes

    - name: "Remove unwanted archive from {{repo_app_dir}} directory"
      file: path={{repo_app_dir}}/{{app_name}}.tar.gz state=absent

    - name: "Remove unwanted archive from {{project_dir}} directory"
      file: path={{project_dir}}/{{app_name}}.tar.gz state=absent
      become: yes
      become_user: root

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;once above playbook is created lets run the Ansible Playbook from that directory you a have created the playbook yaml file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible-playbook ansible-demo.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will find the result like below image.That's it you have successfully ran you Ansible playbook&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/BJ-BpAM48pV8HbC08Cl5Wm12fJ4qedfzvQDrIZyUmP4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzB3Y2th/M21vMzl4ZWQ1a3Ew/OTB4LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/BJ-BpAM48pV8HbC08Cl5Wm12fJ4qedfzvQDrIZyUmP4/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzB3Y2th/M21vMzl4ZWQ1a3Ew/OTB4LnBuZw" alt="Ansible playook" width="880" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Visit your remote server URL to see the angular web app.&lt;/p&gt;

&lt;p&gt;Thanks for reading the blog I hope you enjoyed learning something new today.&lt;/p&gt;

&lt;p&gt;The above blog is submitted as part of 'Devtron Blogathon 2022' - &lt;a href="https://devtron.ai/"&gt;https://devtron.ai/&lt;/a&gt;&lt;br&gt;
Check out Devtron's GitHub repo - &lt;a href="https://github.com/devtron-labs/devtron/"&gt;https://github.com/devtron-labs/devtron/&lt;/a&gt; and give a ⭐ to show your love &amp;amp; support.&lt;br&gt;
Follow Devtron on LinkedIn - &lt;a href="https://www.linkedin.com/company/devtron-labs/"&gt;https://www.linkedin.com/company/devtron-labs/&lt;/a&gt; and Twitter - &lt;a href="https://twitter.com/DevtronL/"&gt;https://twitter.com/DevtronL/&lt;/a&gt;, to keep yourself updated on this Open Source project.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>tutorials</category>
      <category>ansible</category>
    </item>
    <item>
      <title>Let's Create Multi-Stage Container Image with React.js and Nginx</title>
      <dc:creator>kingsathurthi</dc:creator>
      <pubDate>Thu, 26 May 2022 18:07:57 +0000</pubDate>
      <link>https://community.ops.io/kingsathurthi/lets-create-multi-stage-container-image-with-reactjs-and-nginx-54cp</link>
      <guid>https://community.ops.io/kingsathurthi/lets-create-multi-stage-container-image-with-reactjs-and-nginx-54cp</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In this post we are going to look how to build multi-stage container image with React.js and Nginx. React.js is a free and open-source front-end JavaScript library for building user interfaces based on UI components and Nginx is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache but we are going to use as web server for the react.js web app&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Docker Desktop installed&lt;/li&gt;
&lt;li&gt;VS Code or your favorite editor&lt;/li&gt;
&lt;li&gt;Node.js latest version&lt;/li&gt;
&lt;li&gt;NPM latest version&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create React App
&lt;/h2&gt;

&lt;p&gt;Now, let's create a simple React app using the create-react-app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app react-demo
cd react-demo
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now view react-demo in the browser using below localhost link.&lt;/p&gt;

&lt;p&gt;Localhost: (&lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;That's it you have created your first simple react app.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Now we are running react app as development server in local dev environment. If you want to run the same app in production use this &lt;code&gt;npm run build&lt;/code&gt; command instead of &lt;code&gt;npm start&lt;/code&gt; to generate the build file react app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Create Docker file
&lt;/h2&gt;

&lt;p&gt;A Dockerfile is a text document that contains all the commands  to create an container image. Using &lt;code&gt;docker build .&lt;/code&gt; command to execute the image building process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/TWFF3BAiAEzCrut2BT29eCMCOA0CoP08m2aMr1vwjeU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2phc21i/aXZjczBudnZkcmt6/ZXFuLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/TWFF3BAiAEzCrut2BT29eCMCOA0CoP08m2aMr1vwjeU/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL2phc21i/aXZjczBudnZkcmt6/ZXFuLnBuZw" alt="Dockerfile" width="656" height="373"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:slim
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "start"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that create &lt;code&gt;.dockerignore&lt;/code&gt; and add below mentioned file to avoid getting copied into to container image while building&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/k55qI7EjYVgIFPv-s39PLttxPHlBXOYf-HRr4FpQIjo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzE2aGU0/Y2ZyOGQ5NXZ6bGp2/N2NlLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/k55qI7EjYVgIFPv-s39PLttxPHlBXOYf-HRr4FpQIjo/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzLzE2aGU0/Y2ZyOGQ5NXZ6bGp2/N2NlLnBuZw" alt=".dockerignore" width="597" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can start building container image using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t react-demo .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you run the above command image building process looks like below &lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/HXTpytU47qJ-wNnqBXtSnzfJXIzhiVT1pnEVK7zUALw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3k0bXdu/am16ZjJ6dThiODRk/bmY0LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/HXTpytU47qJ-wNnqBXtSnzfJXIzhiVT1pnEVK7zUALw/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3k0bXdu/am16ZjJ6dThiODRk/bmY0LnBuZw" alt="Docker build" width="880" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it you have created your first container image.&lt;/p&gt;

&lt;p&gt;let's run and see the react app using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 3000:3000 react-demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now view react-demo app running as container using same localhost link below.&lt;/p&gt;

&lt;p&gt;Localhost: (&lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Above react container is running as development server Now we will create production grade image using below docker file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://community.ops.io/images/e7Ul5NPMedxTzMFi2QdIOzTIvcT1zSBF8snOf5dCYSI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3BzczJo/cmUzdWU0NzA1ZTUx/eG03LnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/e7Ul5NPMedxTzMFi2QdIOzTIvcT1zSBF8snOf5dCYSI/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL3BzczJo/cmUzdWU0NzA1ZTUx/eG03LnBuZw" alt="Dockerfile" width="880" height="320"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:slim AS builder
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

FROM nginx
EXPOSE 80
COPY --from=builder /app/build /usr/share/nginx/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can start building multi-stage container image using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t react-nginx-demo .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://community.ops.io/images/CvnpfWEgvjtcKGCPwE6Drh1T0S2LYYK48Xug1RXnuys/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL240Ymd6/Mjh2YnRycGg3d2Zm/MDlnLnBuZw" class="article-body-image-wrapper"&gt;&lt;img src="https://community.ops.io/images/CvnpfWEgvjtcKGCPwE6Drh1T0S2LYYK48Xug1RXnuys/w:880/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL2Fy/dGljbGVzL240Ymd6/Mjh2YnRycGg3d2Zm/MDlnLnBuZw" alt="Docker Build" width="880" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it you have successfully created your first multi-stage container image for production.&lt;/p&gt;

&lt;p&gt;let's run and see the react app using below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 80:80 react-nginx-demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;visit to the locahost (&lt;a href="http://localhost"&gt;http://localhost&lt;/a&gt;) Now you can see the react-nginx-demo app running as container.&lt;/p&gt;

&lt;p&gt;That's it for now i hope this blog give you some idea to create production grade container image using multi-stage build process.&lt;/p&gt;

&lt;p&gt;The above blog is submitted as part of 'Devtron Blogathon 2022' - &lt;a href="https://devtron.ai/"&gt;https://devtron.ai/&lt;/a&gt;&lt;br&gt;
Check out Devtron's GitHub repo - &lt;a href="https://github.com/devtron-labs/devtron/"&gt;https://github.com/devtron-labs/devtron/&lt;/a&gt; and give a ⭐ to show your love &amp;amp; support.&lt;br&gt;
Follow Devtron on LinkedIn - &lt;a href="https://www.linkedin.com/company/devtron-labs/"&gt;https://www.linkedin.com/company/devtron-labs/&lt;/a&gt; and Twitter - &lt;a href="https://twitter.com/DevtronL/"&gt;https://twitter.com/DevtronL/&lt;/a&gt;, to keep yourself updated on this Open Source project.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>docker</category>
      <category>tutorials</category>
    </item>
  </channel>
</rss>
