<?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 Abhijeet Kasurde on Medium]]></title>
        <description><![CDATA[Stories by Abhijeet Kasurde on Medium]]></description>
        <link>https://medium.com/@AbhijeetKasurde?source=rss-b13b91202770------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*IDhKGN1Q9HKzPEHtPc6K1Q.jpeg</url>
            <title>Stories by Abhijeet Kasurde on Medium</title>
            <link>https://medium.com/@AbhijeetKasurde?source=rss-b13b91202770------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:26:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@AbhijeetKasurde/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[Ansible: Streamlining Container Management with the Podman connection plugin]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-streamlining-container-management-with-the-podman-connection-plugin-9681e5af2fed?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/9681e5af2fed</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[podman]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 21:37:02 GMT</pubDate>
            <atom:updated>2023-07-17T21:37:02.055Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s dynamic IT landscape, containerization has revolutionized the way applications are deployed and managed.</p><p>With <em>podman</em> connection plugin, Ansible users can effortlessly interact with Podman, a powerful container management tool, to automate container workflows, orchestrate deployments, and ensure seamless containerized application management.</p><p>In this blog post, we will explore how to leverage the <em>podman</em> connection plugin in Ansible to simplify container management and enhance your automation capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmHzXc3dSMcf2IbArcLkHw.jpeg" /><figcaption>Photo by &lt;a href=”<a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Pankaj Patel&lt;/a&gt; on &lt;a href=”<a href="https://unsplash.com/photos/_SgRNwAVNKw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/photos/_SgRNwAVNKw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><p><strong>Understanding the Podman Connection Plugin</strong><br>The podman connection plugin in Ansible allows users to interact with podman using podman command. By integrating Podman with Ansible, users can leverage familiar Ansible modules and playbooks to manage container instances and execute container-related tasks on remote systems. The podman connection plugin extends Ansible’s capabilities to encompass the world of containerization, making it an essential tool for DevOps and infrastructure teams.</p><p><strong>Benefits of Using the Podman Connection Plugin</strong></p><ol><li>Simplified Container Management: With the Podman connection plugin, Ansible users can perform container management tasks with ease.</li><li>Consistent and Scalable Container Orchestration: Ansible’s declarative approach to automation ensures that container configurations remain consistent across multiple systems.</li><li>Seamless Integration with Ansible Ecosystem: The Podman connection plugin seamlessly integrates with Ansible’s vast ecosystem of modules, roles, and playbooks. Users can combine Podman tasks with other automation tasks, allowing for comprehensive application deployment and management workflows.</li><li>Enhanced Security and Isolation: By leveraging the Podman connection plugin, Ansible users can implement secure containerization practices and mitigate potential security risks.</li></ol><p><strong>Using the Podman Connection Plugin in Ansible</strong></p><p>To start using the Podman connection plugin in Ansible, follow these steps:</p><p><strong>Install Podman</strong><br>Ensure that Podman is installed on the target systems</p><p><strong>Install containers.podman collection</strong></p><pre>ansible-galaxy collection install containers.podman</pre><p><strong>Write Ansible Playbooks for Container Management</strong></p><p>Create Ansible playbooks that leverage the podman connection plugin to manage containers. For example:</p><pre>---<br>- hosts: localhost<br>  tasks:<br>    - name: Create a data container<br>      containers.podman.podman_container:<br>        name: &quot;{{ lookup(&#39;community.general.random_pet&#39;, words=3, separator=&#39;_&#39;) }}&quot;<br>        image: python:alpine3.18<br>        command: &quot;sleep 1d&quot;<br>      register: r<br><br>    - name: Add container as a host<br>      ansible.builtin.add_host:<br>        hostname: &quot;{{ r[&#39;container&#39;][&#39;Name&#39;] }}&quot;<br>        groups: &quot;containers&quot;<br><br>- hosts: containers<br>  connection: containers.podman.podman<br>  tasks:<br>    - shell: ls /</pre><p>In this example, we use the <em>containers.podman.podman_container</em> module to create a new container running the latest Python image. We then add this newly created container to Ansible Inventory in hostgroup called containers .</p><p>Execute the Ansible playbook against the target hosts using the podman connection plugin. Ansible will interact with podman, executing the specified container management tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjOnFMlHfNv9fdyTXNN4IA.png" /><figcaption>Running ls command on container using podman connection plugin</figcaption></figure><p>Read more about the podman connection plugin — <a href="https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_connection.html#ansible-collections-containers-podman-podman-connection">https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_connection.html#ansible-collections-containers-podman-podman-connection</a></p><p><strong>Conclusion</strong></p><p>The Podman connection plugin in Ansible empowers users to streamline container management and orchestration. By integrating Podman with Ansible, organizations can leverage the power of automation to deploy and manage containerized applications efficiently.</p><p>Happy Automating</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9681e5af2fed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible: Generating Unique Names with random_pet]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-generating-unique-names-with-random-pet-c10821bdff11?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/c10821bdff11</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 20:44:25 GMT</pubDate>
            <atom:updated>2023-07-17T20:44:25.574Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible offers a wide range of features that simplify complex tasks and streamline operations. One such feature is the <em>random_pet</em> lookup plugin, which enables the generation of unique and random names for resources, variables, or identifiers.</p><p>In this blog post, we will explore the <em>random_pet</em> lookup plugin in Ansible and how it can be leveraged to generate creative and distinctive names for various use cases.</p><p><strong>Understanding the <em>random_pet </em>lookup plugin</strong></p><p>The <em>random_pet</em> lookup plugin is a useful component of Ansible that generates random names based on dictionaries of adjectives and nouns. It can be employed to create unique names for resources, such as virtual machines, containers, network interfaces, or any other element that requires a memorable and distinctive identifier.</p><p>By using the <em>random_pet</em> plugin, you can avoid the hassle of manually generating names and enjoy the benefits of automation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*305-yqKD03Go0XwNP7Beuw.jpeg" /><figcaption>Photo by BRUNO CERVERA on &lt;a href=”<a href="https://unsplash.com/photos/azsk_6IMT3I?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/photos/azsk_6IMT3I?utm_source=unsplash&amp;utm_medium=referral</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><p><strong>Using random_pet in Ansible Playbooks</strong></p><p>To use the <em>random_pet</em> plugin in your Ansible playbooks, follow these steps:</p><p><strong>Install the required collection</strong></p><p>Ensure that the <em>random_pet</em> plugin is installed on your Ansible control machine. You can install it using the following command:</p><pre>ansible-galaxy collection install community.general</pre><p><strong>Install the required Python library</strong></p><p>The random_pet plugin is uses Python package called <a href="https://launchpad.net/python-petname">petname</a>. In order to make random_pet plugin work, you need to install this library. You can install it using the following command:</p><pre>pip3 install petname</pre><p><strong>Define the random name generation</strong></p><p>In your playbook, utilize the <em>random_pet</em> plugin to generate unique names.</p><p>Here’s an example:</p><pre>---<br>- hosts: localhost<br>  tasks:<br>    - debug:<br>        msg: &quot;{{ lookup(&#39;community.general.random_pet&#39;, words=3) }}&quot;</pre><p>In the above code snippet, we use the <em>community.general.random_pet </em>plugin to generate a random pet name. The `words` parameter specifies the number of words to include in the name (e.g., 2 for “adjective-noun” format).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekDMTrj0mCHQ9y-MOhcOhg.png" /><figcaption>random_pet in action</figcaption></figure><p><strong>Utilize the generated name</strong></p><p>Once the name is generated, you can access it using the registered variable (`generated_name`) in subsequent tasks or utilize it as required within your playbook.</p><p>For example, you can use the generated name to create a virtual machine or assign it as a label to a network interface.</p><pre>- name: Create a virtual machine<br>  my_cloud_provider_module:<br>    name: &quot;{{ lookup(&#39;community.general.random_pet&#39;, words=3, separator=&quot;_&quot;) }}&quot;<br>    image: &quot;ubuntu&quot;<br>    size: &quot;small&quot;<br>    state: &quot;present&quot;</pre><p>In the above code, we use a hypothetical <em>my_cloud_provider_module</em> to create a virtual machine, assigning the generated name to the <em>name</em> parameter.</p><p>Check <a href="https://docs.ansible.com/ansible/latest/collections/community/general/random_pet_lookup.html">the full documentation of random_pet</a> for more details.</p><p><strong>Conclusion</strong><br>The random_pet plugin in Ansible provides a convenient solution for generating unique and memorable names.</p><p>Happy Automating</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c10821bdff11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible: Leveraging the ServiceNow ITSM Collection for Seamless IT Service Management]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-leveraging-the-servicenow-itsm-collection-for-seamless-it-service-management-8f667c00ac5d?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f667c00ac5d</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[servicenow]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 19:06:33 GMT</pubDate>
            <atom:updated>2023-07-13T19:06:33.722Z</atom:updated>
            <content:encoded><![CDATA[<p>As organizations strive for efficient IT service management (ITSM), automation tools like Ansible have become instrumental in streamlining operations and improving productivity.</p><p>The ServiceNow ITSM collection for Ansible offers a powerful integration between Ansible and ServiceNow’s IT Service Management platform. In this blog post, we will explore how to leverage the ServiceNow ITSM collection to enhance ITSM workflows, automate routine tasks, and promote seamless collaboration between Ansible and ServiceNow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-tykrY-FWy0wPE2e7ZT6Q.jpeg" /><figcaption>Photo by Scott Graham on &lt;a href=”<a href="https://unsplash.com/photos/5fNmWej4tAA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/photos/5fNmWej4tAA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><h3>Understanding the ServiceNow ITSM Collection</h3><p>The ServiceNow ITSM collection is a set of Ansible modules and plugins that enable communication and interaction with the ServiceNow IT Service Management platform. With this collection, organizations can automate ITSM processes, such as incident management, change management, and configuration item (CI) updates, using Ansible playbooks. The collection facilitates bi-directional integration, allowing Ansible to interact with ServiceNow and vice versa.</p><h3>Benefits of Using the ServiceNow ITSM Collection</h3><p><strong>Streamlined ITSM Workflows</strong></p><p>The ServiceNow ITSM collection simplifies and accelerates ITSM workflows by enabling Ansible to interact directly with ServiceNow. It eliminates the need for manual interventions and bridges the gap between IT operations and service management teams.</p><p><strong>Automation of Routine Tasks</strong></p><p>By combining Ansible’s automation capabilities with the ServiceNow ITSM collection, organizations can automate routine tasks and processes. This includes incident creation, change implementation, and updating CI records, leading to improved efficiency and reduced manual effort.</p><p><strong>Consistent and Auditable Processes</strong></p><p>Using Ansible playbooks with the ServiceNow ITSM collection ensures consistent and auditable processes across IT operations. Playbooks define standardized steps for handling incidents, executing changes, and managing configurations, promoting compliance and traceability.</p><p><strong>Enhanced Collaboration</strong></p><p>The integration between Ansible and ServiceNow promotes seamless collaboration between IT teams. It allows for real-time communication and updates between Ansible automation workflows and ServiceNow’s incident, change, and configuration management processes.</p><h3>Using the ServiceNow ITSM Collection in Ansible</h3><p>To leverage the capabilities of the ServiceNow ITSM collection in Ansible, follow these steps:</p><p><strong>Install the ServiceNow ITSM Collection</strong><br>Ensure that you have the ServiceNow ITSM collection installed on your Ansible control machine. You can use the Ansible Galaxy command to install the collection:</p><pre>ansible-galaxy collection install servicenow.itsm</pre><p><strong>Configure ServiceNow Credentials</strong><br>Provide the necessary credentials and connection details for ServiceNow in Ansible’s inventory or variables file. This includes the ServiceNow instance URL, username, password, and any additional configuration parameters required for authentication and communication.</p><pre>    SN_HOST: &quot;{{ sn_host }}&quot;<br>    SN_USERNAME: &quot;{{ sn_username }}&quot;<br>    SN_PASSWORD: &quot;{{ sn_password }}&quot;</pre><p><strong>Define Playbooks</strong><br>Create Ansible playbooks that utilize the modules and plugins provided by the ServiceNow ITSM collection. For example, you can create playbooks to create or update incidents, implement changes, or synchronize CI records between Ansible and ServiceNow.</p><pre>    - name: Create test incident<br>      servicenow.itsm.incident:<br>        caller: admin<br>        state: new<br>        short_description: Test incident<br>        impact: low<br>        urgency: low<br>        attachments:<br>          - path: sample_file.txt<br>      register: result</pre><p><strong>Execute Playbook</strong></p><pre>ansible-playbook incident.yml -v</pre><p><strong>Monitor and Track Results</strong><br>Monitor the execution of Ansible playbooks and track the results within ServiceNow. You can leverage ServiceNow’s reporting and analytics capabilities to gain insights into automation activities and ITSM process compliance.</p><p><strong>Conclusion</strong><br>The ServiceNow ITSM collection empowers organizations to enhance their ITSM workflows by seamlessly integrating Ansible automation with ServiceNow’s IT Service Management platform. By leveraging the automation capabilities of Ansible and the process management features of ServiceNow, organizations can streamline IT operations, automate routine tasks, and foster collaboration across IT teams.</p><p>Happy Automating.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f667c00ac5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible: Using chroot connection plugin]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-using-chroot-connection-plugin-b98ac243e228?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/b98ac243e228</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 17:02:24 GMT</pubDate>
            <atom:updated>2023-07-07T17:02:24.277Z</atom:updated>
            <content:encoded><![CDATA[<p>With its rich set of connection plugins, Ansible offers versatility in connecting to remote systems. In this blog post, we will explore the chroot connection plugin, a powerful feature that allows you to run commands within a chroot environment. We will delve into the benefits and usage of the chroot connection plugin in Ansible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HhfBCVLruIeDZ0CD60jEYw.jpeg" /><figcaption>Photo by Emma Gossett on &lt;a href=”<a href="https://unsplash.com/photos/B645igbiKCw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/photos/B645igbiKCw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><p><strong>Understanding the chroot Connection Plugin</strong></p><p>The chroot connection plugin in Ansible provides a means to execute commands within a chroot environment on a remote system. A chroot environment is an isolated directory tree that functions as the root directory for a specific process, effectively limiting access to the rest of the system. This plugin is particularly useful for performing tasks that require isolation or for managing systems with different operating system versions.</p><p><strong>Install the chroot connection plugin</strong></p><p>Before using the chroot connection plugin, ensure that it is installed on your Ansible control machine. You can install it using the following command:</p><pre>ansible-galaxy collection install community.general</pre><p><strong>Configure the chroot environment</strong></p><p>Set up the chroot environment on the target system by specifying the chroot path and necessary directories. Ensure that the required libraries and dependencies are available within the chroot environment. We will not discuss how to configure chroot environment in this blog.</p><p><strong>Configure the inventory</strong></p><p>In your inventory file, define the connection plugin as “chroot” for the specific host or group of hosts. For example:</p><pre>[chroots]<br>/path/to/chroot ansible_connection=chroot</pre><p>In the above example, /path/to/chroot is configured to use the chroot connection plugin.</p><p><strong>Running tasks within the chroot environment</strong></p><p>Once the chroot connection plugin is set up, you can run tasks within the chroot environment. For example:</p><pre>- name: Run command in chroot<br>  hosts: chroots<br>  tasks:<br>    - name: Run command in chroot<br>      command: ls /</pre><p>In the above code snippet, the chroot command is used to run a command inside the chroot environment. Replace command with the actual command you want to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYRTnresGZ76RU9SSN83_g.png" /><figcaption>Running command within chroot environment</figcaption></figure><p><strong>Conclusion</strong></p><p>The chroot connection plugin in Ansible offers a valuable tool for executing commands within an isolated environment on remote systems. By harnessing this plugin, you can achieve greater control, isolation, and compatibility when managing your IT infrastructure. The chroot connection plugin simplifies the setup and execution of commands within a chroot environment, making it an efficient solution for various use cases, such as software installations, system upgrades, or managing systems with different configurations.</p><p>With Ansible’s chroot connection plugin, you can confidently execute tasks within an isolated environment, minimizing the impact on the host system and ensuring compatibility with specific libraries or dependencies. By incorporating this powerful feature into your Ansible playbook, you can enhance the automation and management of your infrastructure, leading to improved efficiency and a more streamlined IT operations workflow.</p><p>Happy Automating.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b98ac243e228" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible: Creating passwords with constraints using random_string lookup Plugin]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-creating-passwords-with-constraints-using-random-string-lookup-plugin-34210a8edd95?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/34210a8edd95</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 17:33:18 GMT</pubDate>
            <atom:updated>2023-07-06T17:33:18.552Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible, a popular open-source automation tool, offers a wide range of features that simplify IT infrastructure management. Among its powerful capabilities is the ability to generate random passwords, an essential requirement for secure systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2G1ssWp-Q43CbRhTvnX57w.jpeg" /><figcaption>Photo by Towfiqu barbhuiya on &lt;a href=”<a href="https://unsplash.com/photos/FnA5pAzqhMM?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/photos/FnA5pAzqhMM?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><p>In this blog post, we will explore how to create passwords with specific constraints using the random_string lookup plugin in Ansible. With this technique, you can easily generate complex and secure passwords while adhering to specific requirements.</p><p><strong>Understanding the random_string Lookup Plugin</strong></p><p>Ansible provides a multitude of lookup plugins that allow you to retrieve or generate dynamic values during playbook execution. One such plugin is the <em>random_string</em> lookup plugin, which generates random strings based on specified constraints. By utilizing this plugin, you can create passwords that meet your desired complexity, length, and character set criteria.</p><p><strong>Creating Passwords with Constraints</strong></p><p>Let’s go through the steps to generate a password with specific constraints using the <em>random_string</em> lookup plugin.</p><p>To use the <em>random_string</em> lookup plugin, you need to ensure that the required plugins are installed on your Ansible controller. Install the necessary plugins by running the following command:</p><pre>ansible-galaxy collection install community.general</pre><p>Next, you need to define the constraints for your password. These constraints can include criteria such as length, allowed character sets, and specific character requirements. For example, let’s say we want to generate a password that is 12 characters long, includes at least one uppercase letter, one lowercase letter, one digit, and one special character.</p><pre>---<br>- hosts: localhost<br>  name: Generate a password with constraints<br>  gather_facts: no<br>  tasks:<br>    - name: Generate password<br>      set_fact:<br>        generated_password: &quot;{{ lookup(&#39;community.general.random_string&#39;, length=12, min_lower=1, min_upper=1, min_numeric=1, min_special=1, override_special=&#39;-_=+!#$()[]&#39;) }}&quot;<br><br>    - name: Verify the generate password<br>      debug:<br>        var: generated_password</pre><p>In the above code snippet, we use the lookup function with the community.general.random_string plugin to generate a random string. We specify the length as 12 characters and provide the set of allowed characters (including lowercase letters, uppercase letters, digits, and special characters).</p><p>Running the playbook containing the above tasks will output the randomly generated password that adheres to the specified constraints:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQkxJ_FOCn-Pco2bxop_TQ.png" /><figcaption>Generating password using constraints in Ansible</figcaption></figure><p><strong>Conclusion</strong></p><p>Generating passwords that meet specific constraints is essential for ensuring security in IT systems. With Ansible’s random_string lookup plugin, you can easily create complex and secure passwords while adhering to specific length, character set, and complexity requirements. By incorporating this powerful capability into your automation workflows, you can automate the generation of passwords and improve the security posture of your infrastructure. With Ansible’s flexibility and extensive plugin ecosystem, you have the tools at your disposal to create robust and compliant password generation processes.</p><p>Happy Automating.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34210a8edd95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible: Adding an element to the list]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-adding-an-element-to-the-list-9e9464caf37c?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e9464caf37c</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 16:59:25 GMT</pubDate>
            <atom:updated>2023-07-06T16:59:25.145Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog post, we will explore how to add an element to a list in Ansible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sMFgLoOfGh1qBpKTnhTq5w.jpeg" /><figcaption>Photo by &lt;a href=”<a href="https://unsplash.com/@crissyjarvis?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/@crissyjarvis?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Crissy Jarvis&lt;/a&gt; on &lt;a href=”<a href="https://unsplash.com/photos/gdL-UZfnD3I?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/photos/gdL-UZfnD3I?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><p><strong>Understanding Lists in Ansible</strong></p><p>Before diving into adding an element to a list in Ansible, let’s take a moment to understand what lists are and why they are beneficial. In Ansible, a list is a collection of elements, which can be strings, numbers, or even complex data structures. Lists are enclosed in square brackets [ ] and are used to represent multiple values.</p><p>For instance, consider the following example of a simple list containing a few programming languages:</p><pre>programming_languages:<br>  - Python<br>  - Java<br>  - JavaScript</pre><p>The programming_languages list consists of three elements: Python, Java, and JavaScript. Lists provide a convenient way to organize and manage related information within an Ansible playbook or inventory.</p><p>Adding an Element to a List</p><p>To add an element to an existing list in Ansible, we can leverage the set_fact module. This module allows us to set or modify variables dynamically during playbook execution. The set_fact module, combined with Ansible&#39;s powerful Jinja2 templating engine, provides a straightforward method for appending an element to a list.</p><p>Let’s walk through the steps to add an element to a list in Ansible:</p><p><em>Step 1</em> - Access the existing list: First, we need to access the list we want to modify. We can do this by using the vars directive or by referring to an existing variable that holds the list. For demonstration purposes, let&#39;s assume we have a variable called programming_languages that contains our list.</p><p><em>Step 2 </em>- Use set_fact to add an element: Next, we can utilize the set_fact module along with the + operator to add a new element to the list. Here&#39;s an example</p><pre>- name: Add element to a list<br>  set_fact:<br>    programming_languages: &quot;{{ programming_languages + [&#39;Ruby&#39;] }}&quot;</pre><p>In the above code snippet, we append the string &#39;Ruby&#39; to the programming_languages list using the + operator. The result is a new list with the added element.</p><p><em>Step 3 </em>- Verify the updated list: Finally, you can verify the updated list by printing its contents using the debug module:</p><pre>- name: Print the updated list<br>  debug:<br>    var: programming_languages</pre><p>Running the playbook containing the above tasks will display the modified programming_languages list, including the newly added element:</p><pre>TASK [Print the updated list] **************************************************<br>ok: [localhost] =&gt; {<br>    &quot;programming_languages&quot;: [<br>        &quot;Python&quot;,<br>        &quot;Java&quot;,<br>        &quot;JavaScript&quot;,<br>        &quot;Ruby&quot;<br>    ]<br>}</pre><p>Conclusion</p><p>Adding an element to a list in Ansible is a straightforward process that can be accomplished using the set_fact module and Jinja2 templating. By leveraging this capability, you can easily update and manage your lists within Ansible playbooks, providing flexibility and extensibility to your automation workflows. Whether you&#39;re managing infrastructure, configuring applications, or orchestrating complex deployments, Ansible&#39;s ability to work with lists simplifies the manipulation of data and contributes to a more streamlined automation experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e9464caf37c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ansible: Remove element from the list]]></title>
            <link>https://medium.com/@AbhijeetKasurde/ansible-remove-element-from-the-list-b4c0ead696da?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4c0ead696da</guid>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[ansible-tutorial]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Fri, 08 Jul 2022 09:43:17 GMT</pubDate>
            <atom:updated>2022-07-08T09:46:06.707Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uam8YI7JbbaQO5CrSwyrAw.jpeg" /><figcaption>Photo by &lt;a href=”<a href="https://unsplash.com/@artemioz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/@artemioz?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Artem Zhukov&lt;/a&gt; on &lt;a href=”<a href="https://unsplash.com/collections/4435020/desktop?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/collections/4435020/desktop?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><h3>Removing nth element from the list</h3><p>If you have a list my_list as [1,2,3,4,5,6] and want to remove 3rd element from the list then,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c1af17f7104b738a0b6d0615dbd458d/href">https://medium.com/media/2c1af17f7104b738a0b6d0615dbd458d/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UzNiomrchWpqpl1qVagDMA.png" /></figure><h3>Removing nth element from the list by value</h3><p>If you want to remove a element from the list based upon its value then,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad437e982b599c95e861c2196f2dd407/href">https://medium.com/media/ad437e982b599c95e861c2196f2dd407/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJgxhK-5pxijxs8yqabeUA.png" /></figure><p>You can also use reject filter with conjunction with search like this —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81bf626d1c082a5199161f40715f08f7/href">https://medium.com/media/81bf626d1c082a5199161f40715f08f7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqRYv55ddhR-o_DVs4lNUw.png" /></figure><p>Thanks for reading. Happy Automating.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4c0ead696da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identify Vulnerabilities in Container Image using Podman Desktop and Trivy]]></title>
            <link>https://medium.com/@AbhijeetKasurde/identify-vulnerabilities-in-container-image-using-podman-desktop-and-trivy-38315a4d615f?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/38315a4d615f</guid>
            <category><![CDATA[container-security]]></category>
            <category><![CDATA[podman]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Fri, 10 Jun 2022 15:26:54 GMT</pubDate>
            <atom:updated>2022-06-10T15:26:54.154Z</atom:updated>
            <content:encoded><![CDATA[<p>Podman Desktop now supports Docker Desktop Extensions with this <a href="https://github.com/containers/podman-desktop/pull/177">RFE</a> (request for enhancement).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Adu6Sk8oCF2I18OCXibOkQ.jpeg" /><figcaption>Photo by &lt;a href=”<a href="https://unsplash.com/@olloweb?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/@olloweb?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Agence Olloweb&lt;/a&gt; on &lt;a href=”<a href="https://unsplash.com/s/photos/magnifying-glass?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/s/photos/magnifying-glass?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><p>This means we can take advantage of already build Docker Desktop Extensions. Prime example of this is, Aqua’s Trivy extension for Docker Desktop. This extension allows developers to scan container images seamlessly and reducing the friction to create more secure container native application development.</p><h3>Demo</h3><p>I assume that Podman 4.x or Podman machine is already installed on the machine. After this, you need to install <a href="https://podman-desktop.io/">Podman Desktop</a> (0.0.4 and above) as per your operating system.</p><p>Once you have installed Podman Desktop, you will see something like this —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*136yTwdbmZ15GrqpRtENnw.png" /><figcaption>A fresh Installation of Podman Desktop</figcaption></figure><p>Now, let us go to Preferences which will look like —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4L9G8V2h2IUwQrcKCuScKA.png" /><figcaption>Podman Desktop’s Preferences</figcaption></figure><p>Here, you can install Docker Desktop Extensions . For this demo, let us install trivy Docker Desktop extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nk72wUstxOgnF1ni98b1qA.png" /><figcaption>Installation of Trivy Docker Desktop Extension</figcaption></figure><p>After successful installation extension, you can visit Trivy menu in left hand panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ys-vJJDay1M_V9vfh3Oddw.png" /><figcaption>Welcome Screen</figcaption></figure><p>You can scan a container image by providing container image in the given text box and hit Scan Image .</p><p>Let us try to scan ansible/ansible-runner container image —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q34k21H0DYEonP0efYZB0w.png" /><figcaption>A list of vulnerabilities for the given container image</figcaption></figure><p>As a developer, this is a great feature which allows seamless scanning of container images and improving the security in containers.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38315a4d615f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Kubernetes Admission Controllers]]></title>
            <link>https://medium.com/@AbhijeetKasurde/using-kubernetes-admission-controllers-1e5ba5cc30c0?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e5ba5cc30c0</guid>
            <category><![CDATA[trivy]]></category>
            <category><![CDATA[container-orchestration]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[vulnerability]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Wed, 25 May 2022 13:13:19 GMT</pubDate>
            <atom:updated>2022-05-25T13:13:19.193Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will use k8s Admission Controller for scanning images used in the given pod definition using <a href="https://github.com/aquasecurity/trivy">trivy</a>.</p><p>Kubernetes provides users a wide variety options for container management and additional configurations to optimize the infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K9JVlwhSBRJucuX8vW8TmA.jpeg" /><figcaption>Photo by &lt;a href=”<a href="https://unsplash.com/@vork?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/@vork?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Mark Boss&lt;/a&gt; on &lt;a href=”<a href="https://unsplash.com/s/photos/traffic-police?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">https://unsplash.com/s/photos/traffic-police?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText</a>&quot;&gt;Unsplash&lt;/a&gt;</figcaption></figure><h3>What is Admission Controller ?</h3><p>Admission controller is a piece of software that intercepts requests to the Kubernetes API server prior to persistence of the object, but after the request is authenticated and authorized. This way we can do various operations like validation and mutation on the given object.</p><p>Admission controllers may be “validating”, “mutating”, or both. Mutating controllers may modify related objects to the requests they admit. Whereas validating controllers may not modify the related objects but validate them as per requirement.</p><p>You can read more about admission controller in <a href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/">the official documentation</a>.</p><p>In this article, we are going to use “Validating” Admission Controller to scan images provided in the given pod definition. This scan enables us to see if the pod definition is vulnerable or not.</p><p>For scanning the image, we are going to use trivy . Trivy is a simple and comprehensive scanner for vulnerabilities in container images, file systems, and Git repositories, as well as for configuration issues. You can find more details about <a href="https://github.com/aquasecurity/trivy">trivy</a> GitHub page.</p><h3>Demo</h3><p>Let us first create a flask application as an external admission controller which will be called while validation part.</p><p>To begin with, we will create a self-signed certificate for Python Flask application as Kubernetes require “<em>https”</em> connection between API server and admission controller.</p><p>Using openssl commands, we can create a root CA and a self-signed certificate for the flask application</p><pre>#!/bin/bash</pre><pre>echo &quot;Creating certificates&quot;<br>mkdir -p certs/ca</pre><pre># Create a root CA<br>openssl genrsa -out certs/ca/ca.key 2048</pre><pre>openssl req -new -key certs/ca/ca.key -out certs/ca/ca.csr<br>openssl x509 -req -in certs/ca/ca.csr -out certs/ca/ca-cert.crt -signkey certs/ca/ca.key -days &quot;3650&quot;</pre><pre># Create a self-signed server certificate using above CA certificate<br>openssl genrsa -out certs/server.key 2048<br>openssl req -new -key certs/server.key -out certs/server.csr -subj &quot;/CN=$(hostname)&quot;<br>hostname=$(hostname)<br>openssl x509 -req -extfile &lt;(printf &quot;subjectAltName=DNS:$hostname&quot;) -in certs/server.csr -signkey certs/server.key -out certs/server.crt -CA certs/ca/ca-cert.crt -CAkey certs/ca/ca.key -days 3650 -CAcreateserial</pre><p>Once you have certificates ready, you can proceed with simple flask application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/615032e8f619e67c2ef73c388b37bb9b/href">https://medium.com/media/615032e8f619e67c2ef73c388b37bb9b/href</a></iframe><p>The code is pretty straight forward. Using a simple flask application, we will create an API server with single route called /validate which will handle “validation” part. The /validate route invokes trivy command line and passes various image names available in the given pod definition. Depending upon the command result, route decides whether to allow pod creation or deny it. Line 47, shows the SSL certificates being used for the flask application.</p><p>Let us start the server —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHMOAhdQ9RtsLztoWK2M-Q.png" /><figcaption>External Admission Controller</figcaption></figure><p>Now, let us make Kubernetes aware about this external admission controller using ValidatingWebhookConfiguration object. You can read about the configuration object in <a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/">the official Kubernetes documentation</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8ce422a7d08941aaf2ca09c0cae78fd/href">https://medium.com/media/c8ce422a7d08941aaf2ca09c0cae78fd/href</a></iframe><p>Here, we created a list of rules used to determine if a request to the API server should be sent to the webhook. If an incoming request matches one of the specified operations, groups, versions, resources, and scope for any of a webhook’s rules, the request is sent to the webhook. In this example, we are just concerned about CREATE requests to apps/v1 and apps/v1beta1 while considering Pods .</p><p>Create ValidatingWebhookConfiguration object like —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCh-587XNNqSJMh36-6udA.png" /><figcaption>Kubectl command</figcaption></figure><p>Now, we will test this setup by creating a pod with vulnerable image —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6868606f6cd78a28bc2c75f96bccbff4/href">https://medium.com/media/6868606f6cd78a28bc2c75f96bccbff4/href</a></iframe><p>here, nginx image has HIGH vulnerabilities. If we try to create a pod using this manifest file, our admission controller will kick-in and deny the requests</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OVVFPLbBNZhQ7G0LmDFyeQ.png" /></figure><p>If you change the image name with less vulnerabilities (for example — `python:3.7-alpine`), admission controller will allow creation of the pod like —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjkQ0z6Yj_R9HyQhnzxgww.png" /></figure><p>You can check out the whole source code of this project at my GitHub <a href="https://github.com/Akasurde/trivy_admission_controller">repo</a>.</p><p>Thanks, for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e5ba5cc30c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom datatype in ‘Click’ for input validation]]></title>
            <link>https://medium.com/@AbhijeetKasurde/custom-datatype-in-click-481f534ad5e2?source=rss-b13b91202770------2</link>
            <guid isPermaLink="false">https://medium.com/p/481f534ad5e2</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[click]]></category>
            <dc:creator><![CDATA[Abhijeet Kasurde]]></dc:creator>
            <pubDate>Mon, 11 Apr 2022 05:43:21 GMT</pubDate>
            <atom:updated>2022-04-11T05:45:44.121Z</atom:updated>
            <content:encoded><![CDATA[<p>Adding validation to your command line arguments using Click</p><p>When you want to add a validation to your command line arguments while using ‘<a href="https://click.palletsprojects.com/en/8.1.x/">Click</a>’, you can use custom validation class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I5KDnulItdfOihFQKkGKkA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@danielkorpai?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Daniel Korpai</a> on <a href="https://unsplash.com/s/photos/computer-screen?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>For example, if you are accepting IP address from command line parameter, and validating it in your Python code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQXGf9RXm_4QLSfN0zD6Jw.png" /><figcaption>A program accepting a valid IP address</figcaption></figure><p>Here, you can use a custom validation class which inherits click.ParamType like —</p><pre>import click<br>import re<br></pre><pre>class IPAddress(click.ParamType):<br>    name = &#39;ipaddress&#39;</pre><pre>def convert(self, value, param, ctx):<br>    ip_address = &quot;^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$&quot;<br>    found = re.match(ip_address, value)</pre><pre>    if not found:<br>        self.fail(<br>            f&#39;{value} is not a valid IP address&#39;,<br>            param,<br>            ctx,<br>        )</pre><pre>    return value</pre><pre><a href="http://twitter.com/click">@click</a>.command(no_args_is_help=True)<br><a href="http://twitter.com/click">@click</a>.option(&#39;--ip-address&#39;, type=IPAddress(), help=&#39;A valid IP address&#39;)<br>def hello(ip_address):<br>    click.echo(&#39;Your IP address is %s!&#39; % ip_address)</pre><pre>if __name__ == &#39;__main__&#39;:<br>    hello()</pre><p>In this example, I am using a regex to valid the IP address. The IP address validation is taken from the <a href="https://uibakery.io/regex-library/ip-address-regex-python">UI Bakery</a>. The code is pretty straight forward.</p><h3>Demo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuvLiQ8JS6BRYEw2Ej_0hg.png" /><figcaption>An Invalid IP address provided by user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIGZXU_09zzVjPRxhifs5Q.png" /><figcaption>A valid IP address provided by user</figcaption></figure><p>You can read more about click.ParamType <a href="https://click.palletsprojects.com/en/8.1.x/api/#click.ParamType">here</a>. Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=481f534ad5e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>