<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>100DaysToOffLoad &amp;mdash; sandeepk</title>
    <link>https://blogs.dgplug.org/sandeepk/tag:100DaysToOffLoad</link>
    <description></description>
    <pubDate>Fri, 24 Apr 2026 20:12:45 +0000</pubDate>
    <item>
      <title>sh like infix syntax using Pipes(|) in Python</title>
      <link>https://blogs.dgplug.org/sandeepk/sh-like-infix-syntax-using-pipes-in-python</link>
      <description>&lt;![CDATA[Today, we are going to see how we can use | operator in our python code to achieve clean code. &#xA;&#xA;Here is the code where we have used map and filter for a specific operation.&#xA;In [1]: arr = [11, 12, 14, 15, 18]&#xA;In [2]: list(map(lambda x: x  2, filter(lambda x: x%2 ==1, arr)))&#xA;Out[2]: [22, 30]&#xA;The same code with Pipes.&#xA;In [1]: from pipe import select, where&#xA;In [2]: arr = [11, 12, 14, 15, 18]&#xA;In [3]: list(arr | where (lambda x: x%2 ==1) | select(lambda x:x 2))&#xA;Out[3]: [22, 30]&#xA;Pipes passes the result of one function to another function, have inbuilt pipes method like select, where, tee, traverse. &#xA;&#xA;Install Pipe&#xA;    pip install pipe&#xA;traverse&#xA;Recursively unfold iterable:&#xA; In [12]: arr = [[1,2,3], [3,4,[56]]]&#xA;In [13]: list(arr | traverse)&#xA;Out[13]: [1, 2, 3, 3, 4, 56]&#xA;select()&#xA; An alias for map().&#xA;In [1]: arr = [11, 12, 14, 15, 18]&#xA;In [2]: list(filter(lambda x: x%2 ==1, arr))&#xA;Out[2]: [11, 15]&#xA;where()&#xA;Only yields the matching items of the given iterable:&#xA;In [1]: arr = [11, 12, 14, 15, 18]&#xA;In [2]: list(arr | where(lambda x: x % 2 == 0))&#xA;Out[2]: [12, 14, 18]&#xA;sort()&#xA;Like Python&#39;s built-in &#34;sorted&#34; primitive. Allows cmp (Python 2.x&#xA;only), key, and reverse arguments. By default, sorts using the&#xA;identity function as the key.&#xA;In [1]:  &#39;&#39;.join(&#34;python&#34; | sort)&#xA;Out[1]:  &#39;hnopty&#39;&#xA;reverse&#xA;Like Python&#39;s built-in &#34;reversed&#34; primitive.&#xA;In [1]:  list([1, 2, 3] | reverse)&#xA;Out[1]:   [3, 2, 1]&#xA;strip&#xA;Like Python&#39;s strip-method for str.&#xA;In [1]:  &#39;  abc   &#39; | strip&#xA;Out[1]:  &#39;abc&#39;&#xA;&#xA;That&#39;s all for today, In this blog you have seen how to install the Pipe and use the Pipe to write clean and short code using inbuilt pipes, you can check more over here&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Python&#xA;DGPLUG]]&gt;</description>
      <content:encoded><![CDATA[<p>Today, we are going to see how we can use <em>|</em> operator in our python code to achieve clean code.</p>

<p>Here is the code where we have used map and filter for a specific operation.</p>

<pre><code class="language-python">In [1]: arr = [11, 12, 14, 15, 18]
In [2]: list(map(lambda x: x * 2, filter(lambda x: x%2 ==1, arr)))
Out[2]: [22, 30]
</code></pre>

<p>The same code with Pipes.</p>

<pre><code>In [1]: from pipe import select, where
In [2]: arr = [11, 12, 14, 15, 18]
In [3]: list(arr | where (lambda x: x%2 ==1) | select(lambda x:x *2))
Out[3]: [22, 30]
</code></pre>

<p>Pipes passes the result of one function to another function, have inbuilt pipes method like <strong>select</strong>, <strong>where</strong>, <strong>tee</strong>, <strong>traverse</strong>.</p>

<h3 id="install-pipe">Install Pipe</h3>

<pre><code class="language-shell">&gt;&gt; pip install pipe
</code></pre>

<h3 id="traverse">traverse</h3>

<p>Recursively unfold iterable:</p>

<pre><code class="language-python">In [12]: arr = [[1,2,3], [3,4,[56]]]
In [13]: list(arr | traverse)
Out[13]: [1, 2, 3, 3, 4, 56]
</code></pre>

<h3 id="select">select()</h3>

<p> An alias for map().</p>

<pre><code class="language-python">In [1]: arr = [11, 12, 14, 15, 18]
In [2]: list(filter(lambda x: x%2 ==1, arr))
Out[2]: [11, 15]
</code></pre>

<h3 id="where">where()</h3>

<p>Only yields the matching items of the given iterable:</p>

<pre><code class="language-python">In [1]: arr = [11, 12, 14, 15, 18]
In [2]: list(arr | where(lambda x: x % 2 == 0))
Out[2]: [12, 14, 18]
</code></pre>

<h3 id="sort">sort()</h3>

<p>Like Python&#39;s built-in “sorted” primitive. Allows cmp (Python 2.x
only), key, and reverse arguments. By default, sorts using the
identity function as the key.</p>

<pre><code class="language-python">In [1]:  &#39;&#39;.join(&#34;python&#34; | sort)
Out[1]:  &#39;hnopty&#39;
</code></pre>

<h3 id="reverse">reverse</h3>

<p>Like Python&#39;s built-in “reversed” primitive.</p>

<pre><code class="language-python">In [1]:  list([1, 2, 3] | reverse)
Out[1]:   [3, 2, 1]
</code></pre>

<h3 id="strip">strip</h3>

<p>Like Python&#39;s strip-method for str.</p>

<pre><code class="language-python">In [1]:  &#39;  abc   &#39; | strip
Out[1]:  &#39;abc&#39;
</code></pre>

<p>That&#39;s all for today, In this blog you have seen how to install the Pipe and use the Pipe to write clean and short code using inbuilt pipes, you can check more over <a href="https://github.com/JulienPalard/Pipe#existing-pipes-in-this-module" rel="nofollow">here</a></p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Python</span></a>
<a href="/sandeepk/tag:DGPLUG" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">DGPLUG</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/sh-like-infix-syntax-using-pipes-in-python</guid>
      <pubDate>Mon, 29 Nov 2021 14:18:04 +0000</pubDate>
    </item>
    <item>
      <title>Profiling Django Application</title>
      <link>https://blogs.dgplug.org/sandeepk/profiling-django-application</link>
      <description>&lt;![CDATA[My work required me to profile one of our Django applications, to help identify the point in the application which we can improve to reach our North Star. So, I thought it will be great to share my learning and tools, that I have used to get the job done.&#xA;&#xA;What is Profiling?&#xA;Profiling) is a measure of the time or memory consumption of the running program. This data further can be used for program optimization.&#xA;&#xA;They are many tools/libraries out there which can be used to do the job. I have found these helpful.&#xA;&#xA;Apache JMeter&#xA;It is open-source software, which is great to load and performance test web applications. It&#39;s easy to set up and can be configured for what we want in the result report.&#xA;&#xA;Pyinstrument&#xA;Pyinstrument is a Python profiler that offers a Django middleware to record the profiling. The profiler generates profile data for every request. The PYINSTRUMENTPROFILEDIR contains a directory that stores the profile data, which is in HTML format. You can check how it works over here&#xA;&#xA;Django Query Count&#xA;Django Query Count is a middleware that prints the number of database queries made during the request processing. There are two possible settings for this, which can be found here&#xA;&#xA;Django Silk&#xA;Django Silk is middleware for intercepting Requests/Responses. We can profile a block of code or functions, either manually or dynamically. It also has a user interface for inspection and visualization &#xA;&#xA;So, here are some of the tools which can be of great help in profiling your code and putting your effort in the right direction of optimization applications.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Python&#xA;DGPLUG&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>My work required me to profile one of our Django applications, to help identify the point in the application which we can improve to reach our North Star. So, I thought it will be great to share my learning and tools, that I have used to get the job done.</p>

<h2 id="what-is-profiling">What is Profiling?</h2>

<p><a href="https://en.wikipedia.org/wiki/Profiling_(computer_programming)" rel="nofollow">Profiling</a> is a measure of the time or memory consumption of the running program. This data further can be used for program optimization.</p>

<p>They are many tools/libraries out there which can be used to do the job. I have found these helpful.</p>

<h2 id="apache-jmeter-https-jmeter-apache-org"><a href="https://jmeter.apache.org/" rel="nofollow">Apache JMeter</a></h2>

<p>It is open-source software, which is great to load and performance test web applications. It&#39;s easy to set up and can be configured for what we want in the result report.</p>

<h2 id="pyinstrument-https-pyinstrument-readthedocs-io-en-latest-home-html"><a href="https://pyinstrument.readthedocs.io/en/latest/home.html" rel="nofollow">Pyinstrument</a></h2>

<p>Pyinstrument is a Python profiler that offers a Django middleware to record the profiling. The profiler generates profile data for every request. The PYINSTRUMENT<em>PROFILE</em>DIR contains a directory that stores the profile data, which is in HTML format. You can check how it works over <a href="https://pyinstrument.readthedocs.io/en/latest/how-it-works.html" rel="nofollow">here</a></p>

<h2 id="django-query-count-https-github-com-bradmontgomery-django-querycount"><a href="https://github.com/bradmontgomery/django-querycount" rel="nofollow">Django Query Count</a></h2>

<p>Django Query Count is a middleware that prints the number of database queries made during the request processing. There are two possible settings for this, which can be found <a href="https://github.com/bradmontgomery/django-querycount#settings" rel="nofollow">here</a></p>

<h2 id="django-silk-https-github-com-jazzband-django-silk"><a href="https://github.com/jazzband/django-silk" rel="nofollow">Django Silk</a></h2>

<p>Django Silk is middleware for intercepting Requests/Responses. We can profile a block of code or functions, either manually or dynamically. It also has a user interface for inspection and visualization</p>

<p>So, here are some of the tools which can be of great help in profiling your code and putting your effort in the right direction of optimization applications.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Python</span></a>
<a href="/sandeepk/tag:DGPLUG" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">DGPLUG</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/profiling-django-application</guid>
      <pubDate>Sun, 28 Nov 2021 12:00:31 +0000</pubDate>
    </item>
    <item>
      <title>Attaching Visual Studio Code(Text Editor) to a running container</title>
      <link>https://blogs.dgplug.org/sandeepk/attaching-visual-studio-code-to-a-container</link>
      <description>&lt;![CDATA[Nowadays, every project  has a docker image,  to ease out the local setup and deployment process. We can attach these running container to our editor and can do changes on the go. We will be talking about the VS Code editor and how to use it to attach to the running container.&#xA;&#xA;First thing first, run your container image and open up the VS Code editor, you will require to install following plugin &#xA;&#xA;Remote-Container&#xA;Remote Development&#xA;&#xA;Now, after installing these plugins, follow the steps below.&#xA;&#xA;Press the F1 key to open Command Palette and choose Remote-Containers: Attach to Running Container...&#xA;VS Code Palette&#xA;Choose your running container from the list, and voilà.&#xA;After this step, a new VS Code editor will open, which will be connected to your code.&#xA;VS Code bar&#xA;You need to re-install plugin for this again form marketplace.  &#xA;&#xA;After this, you are all set to playground the code.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;VSCode&#xA;Containers&#xA;Docker&#xA;&#xA; &#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Nowadays, every project  has a docker image,  to ease out the local setup and deployment process. We can attach these running container to our editor and can do changes on the go. We will be talking about the VS Code editor and how to use it to attach to the running container.</p>

<p>First thing first, run your container image and open up the VS Code editor, you will require to install following plugin</p>
<ol><li><a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers" rel="nofollow">Remote-Container</a></li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack" rel="nofollow">Remote Development</a></li></ol>

<p>Now, after installing these plugins, follow the steps below.</p>
<ul><li>Press the <code>F1</code> key to open Command Palette and choose Remote-Containers: Attach to Running Container...
<img src="https://raw.githubusercontent.com/Skchoudhary/blog-asset/master/dgplug-blog/attach_container.jpg" alt="VS Code Palette"></li>
<li>Choose your running container from the list, and voilà.</li>
<li>After this step, a new VS Code editor will open, which will be connected to your code.
<img src="https://raw.githubusercontent.com/Skchoudhary/blog-asset/master/dgplug-blog/vscode-bar.png" alt="VS Code bar"></li>
<li>You need to re-install plugin for this again form marketplace.<br></li></ul>

<p>After this, you are all set to playground the code.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:VSCode" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">VSCode</span></a>
<a href="/sandeepk/tag:Containers" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Containers</span></a>
<a href="/sandeepk/tag:Docker" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Docker</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/attaching-visual-studio-code-to-a-container</guid>
      <pubDate>Sat, 27 Nov 2021 11:39:18 +0000</pubDate>
    </item>
    <item>
      <title>Image Modes</title>
      <link>https://blogs.dgplug.org/sandeepk/image-modes</link>
      <description>&lt;![CDATA[Today we are going to talk about the modes of image. The mode of image defines the depth and type of the pixel. These string values help you understand different information about the image. As of this writing, we have 11 standard modes.&#xA;&#xA;1 (1-bit pixels, black and white, stored with one pixel per byte)&#xA;&#xA;L (8-bit pixels, black and white)&#xA;&#xA;P (8-bit pixels, mapped to any other mode using a color palette)&#xA;&#xA;RGB (3x8-bit pixels, true color)&#xA;&#xA;RGBA (4x8-bit pixels, true color with transparency mask)&#xA;&#xA;CMYK (4x8-bit pixels, color separation)&#xA;&#xA;YCbCr (3x8-bit pixels, color video format)&#xA;&#xA;LAB (3x8-bit pixels, the Lab color space)&#xA;&#xA;HSV (3x8-bit pixels, Hue, Saturation, Value color space)&#xA;&#xA;I (32-bit signed integer pixels)&#xA;&#xA;F (32-bit floating point pixels)&#xA;&#xA;So, 1-bit pixel range from 0-1 and 8-bit pixel range from 0-255. The common modes are RGB, RGBA, P mode. Image also consist of band, common band like RGB for red, green, blue also have an Alpha(A) transparency, mainly for PNG image.&#xA;&#xA;We can also change these modes with the help of convert or creating new image with the help of pillow library. Let see the code for example&#xA;&#xA;here we convert RGBA image to RGB image and painting the Alpha &#xA;trasparency band to white color&#xA;image = Image.open(&#34;path/to/image&#34;)&#xA;image.mode # this will tell image mode&#xA;newimage = Image.new(&#34;RGB&#34;, image.size, (255, 255, 255))&#xA;newimage.paste(image, mask=image.split()[3])&#xA;That&#39;s all about the modes. There is also raw modes where you can create even your modes, but will save that for another blog post :)&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Python&#xA;Pillow&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Today we are going to talk about the modes of image. The mode of image defines the depth and type of the pixel. These string values help you understand different information about the image. As of this writing, we have <strong>11 standard</strong> modes.</p>
<ul><li><p>1 (1-bit pixels, black and white, stored with one pixel per byte)</p></li>

<li><p>L (8-bit pixels, black and white)</p></li>

<li><p>P (8-bit pixels, mapped to any other mode using a color palette)</p></li>

<li><p>RGB (3x8-bit pixels, true color)</p></li>

<li><p>RGBA (4x8-bit pixels, true color with transparency mask)</p></li>

<li><p>CMYK (4x8-bit pixels, color separation)</p></li>

<li><p>YCbCr (3x8-bit pixels, color video format)</p></li>

<li><p>LAB (3x8-bit pixels, the L<em>a</em>b color space)</p></li>

<li><p>HSV (3x8-bit pixels, Hue, Saturation, Value color space)</p></li>

<li><p>I (32-bit signed integer pixels)</p></li>

<li><p>F (32-bit floating point pixels)</p></li></ul>

<p>So, 1-bit pixel range from 0-1 and 8-bit pixel range from 0-255. The common modes are RGB, RGBA, P mode. Image also consist of band, common band like RGB for red, green, blue also have an Alpha(A) transparency, mainly for PNG image.</p>

<p>We can also change these modes with the help of <a href="https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.convert" rel="nofollow">convert</a> or creating new image with the help of pillow library. Let see the code for example</p>

<pre><code class="language-python"># here we convert RGBA image to RGB image and painting the Alpha 
# trasparency band to white color
image = Image.open(&#34;path/to/image&#34;)
image.mode # this will tell image mode
new_image = Image.new(&#34;RGB&#34;, image.size, (255, 255, 255))
new_image.paste(image, mask=image.split()[3])
</code></pre>

<p>That&#39;s all about the modes. There is also raw modes where you can create even your modes, but will save that for another blog post :)</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Python</span></a>
<a href="/sandeepk/tag:Pillow" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Pillow</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/image-modes</guid>
      <pubDate>Fri, 26 Nov 2021 08:08:52 +0000</pubDate>
    </item>
    <item>
      <title>Exchange Image File Format(EXIF) Rotation</title>
      <link>https://blogs.dgplug.org/sandeepk/exchange-image-file-format-exif-rotation</link>
      <description>&lt;![CDATA[The other day, I was working with images which need me to use image EXIF rotation to show in right orientation. Which leads me to read about EXIF, so here are my notes about the same.&#xA;&#xA;What is EXIF&#xA;Exchange image file format is a protocol whose initial definition was produced by Japan Electronic Industries Development Association(JEIDA). It stores the various meta information of the images taken by a digital camera, which is stored as tag and value. There are many tags but for my problem  Orientation (rotation) tag is of interest. The orientation tag value can be from 1 to 8 which signifies different meanings according to the position of the camera while taking the image.&#xA;&#xA;EXIF Meta information from GIMP&#xA;Image metadata from GIMP tool&#xA;&#xA;Different Rotation&#xA;EXIF rotation helps the image viewer application to show the image in the right orientation if it&#39;s compatible with the EXIF metadata. Window users might have noticed that before Window 8 image shown is without rotation, but after Window 8 all images are shown in their right orientation because of the compatibility with EXIF.&#xA;&#xA;Different Rotation&#xA;Above image is taken from this blog&#xA;&#xA;| EXIF Orientation Tag Value |Row | Column |&#xA;| ----------- | ----------- |----------- |&#xA;| 1 | Top| Left Side |&#xA;| 3 |Bottom |Right Side |&#xA;|  6|Right Side |Top|&#xA;| 8 |Left Side | Bottom|&#xA;&#xA;What Problem I have and how EXIF meta helpful&#xA;So, the issue I am trying to solve is that we need to show the user&#39;s uploaded images that can have a different orientation, to fix this we need to rotate images which can be achieved at the server or the browser side. Working with Python makes it easy to handle the image with the help of Pillow library.&#xA;&#xA;Image with rotation 3&#xA;Image with different rotation&#xA;&#xA;from PIL import Image&#xA;&#xA;rotationdict = {3: 180, 6: 270, 8: 90}&#xA;EXIFORIENTATIONTAG = 274&#xA;image = Image.open(image)&#xA;exifdata = image.getexif()&#xA;if exifdata:&#xA;    rotationdegree = rotationdict.get(exifdata.get(EXIFORIENTATIONTAG))&#xA;    if rotationdegree:&#xA;        imagefile = imagefile.rotate(rotationdegree)&#xA;&#xA;This also can be achieved with CSS  image-orientation which can be used with mostly all browser&#xA;&#xA;/ keyword values /&#xA;image-orientation: none;&#xA;image-orientation: from-image; / Use EXIF data from the image /&#xA;&#xA;/ Global values /&#xA;image-orientation: inherit;&#xA;image-orientation: initial;&#xA;image-orientation: revert;&#xA;image-orientation: unset;&#xA;&#xA;At last, I go with the CSS solution, which solves our use case with the least effort/code changes.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;TIL&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>The other day, I was working with images which need me to use image EXIF rotation to show in right orientation. Which leads me to read about EXIF, so here are my notes about the same.</p>

<p><strong>What is EXIF</strong>
Exchange image file format is a protocol whose initial definition was produced by Japan Electronic Industries Development Association(<em>JEIDA</em>). It stores the various meta information of the images taken by a digital camera, which is stored as tag and value. There are many tags but for my problem  <em>Orientation (rotation)</em> tag is of interest. The orientation tag value can be from 1 to 8 which signifies different meanings according to the position of the camera while taking the image.</p>

<p><img src="https://raw.githubusercontent.com/Skchoudhary/blog-asset/master/dgplug-blog/exif-meta.png" alt="EXIF Meta information from GIMP">
<em>Image metadata from GIMP tool</em></p>

<p><strong>Different Rotation</strong>
EXIF rotation helps the image viewer application to show the image in the right orientation if it&#39;s compatible with the EXIF metadata. Window users might have noticed that before Window 8 image shown is without rotation, but after Window 8 all images are shown in their right orientation because of the compatibility with EXIF.</p>

<p><img src="https://raw.githubusercontent.com/Skchoudhary/blog-asset/master/dgplug-blog/orient_flag2.gif" alt="Different Rotation">
<em>Above image is taken from this <a href="https://www.impulseadventure.com/photo/exif-orientation.html" rel="nofollow">blog</a></em></p>

<table>
<thead>
<tr>
<th>EXIF Orientation Tag Value</th>
<th>Row</th>
<th>Column</th>
</tr>
</thead>

<tbody>
<tr>
<td>1</td>
<td>Top</td>
<td>Left Side</td>
</tr>

<tr>
<td>3</td>
<td>Bottom</td>
<td>Right Side</td>
</tr>

<tr>
<td>6</td>
<td>Right Side</td>
<td>Top</td>
</tr>

<tr>
<td>8</td>
<td>Left Side</td>
<td>Bottom</td>
</tr>
</tbody>
</table>

<p><strong>What Problem I have and how EXIF meta helpful</strong>
So, the issue I am trying to solve is that we need to show the user&#39;s uploaded images that can have a different orientation, to fix this we need to rotate images which can be achieved at the server or the browser side. Working with Python makes it easy to handle the image with the help of Pillow library.</p>

<p><img src="https://raw.githubusercontent.com/Skchoudhary/blog-asset/master/dgplug-blog/rotation-3.jpg" alt="Image with rotation 3">
<em>Image with different rotation</em></p>

<pre><code class="language-python">from PIL import Image

rotation_dict = {3: 180, 6: 270, 8: 90}
EXIF_ORIENTATION_TAG = 274
image = Image.open(image)
exif_data = image._getexif()
if exif_data:
    rotation_degree = rotation_dict.get(exif_data.get(EXIF_ORIENTATION_TAG))
    if rotation_degree:
        image_file = image_file.rotate(rotation_degree)

</code></pre>

<p>This also can be achieved with CSS  <code>image-orientation</code> which can be used with mostly all <a href="https://caniuse.com/?search=image-orientation" rel="nofollow">browser</a></p>

<pre><code class="language-css">/* keyword values */
image-orientation: none;
image-orientation: from-image; /* Use EXIF data from the image */

/* Global values */
image-orientation: inherit;
image-orientation: initial;
image-orientation: revert;
image-orientation: unset;
</code></pre>

<p>At last, I go with the CSS solution, which solves our use case with the least effort/code changes.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:TIL" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">TIL</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/exchange-image-file-format-exif-rotation</guid>
      <pubDate>Wed, 24 Nov 2021 06:33:50 +0000</pubDate>
    </item>
    <item>
      <title>Python : Data Class</title>
      <link>https://blogs.dgplug.org/sandeepk/python-data-class</link>
      <description>&lt;![CDATA[A data class is a class containing data only, from Python3.7 we can define a data class with the help of decorator @dataclass, which build the class with the basic functionality like init , repr, eq and more special methods.&#xA;&#xA;Let see how to define your data class with the decorator @dataclass&#xA;from dataclasses import dataclass&#xA;&#xA;@dataclass&#xA;class Batch:&#xA;    sku: int&#xA;    name: str&#xA;    qty: int&#xA;&#xA;      Batch(1, &#39;desk&#39;, 100)&#xA;Batch(sku=1, name=&#39;desk&#39;, qty=100)&#xA;We can also add the default value to the data class, which works exactly as if we do in the init  method of regular class. As you have noticed in the above we have defined the fields with type hints, which is kind of mandatory thing in the data class, if you do not do it will not take the field in your data class.&#xA;&#xA;@dataclass&#xA;class Batch:&#xA;    sku: int = 1&#xA;    name: str = &#39;desk&#39;&#xA;    qty: int = 100&#xA;&#xA;if you don&#39;t want to explicity type the fields you can use any&#xA;from typing import Any&#xA;class AnyBatch:&#xA;    sku: Any&#xA;    name: Any = &#39;desk&#39;&#xA;    qty: Any = 100&#xA;&#xA;If you want to define mutable default value in data class, it can be done with the help of defaultfactory and field. Field() is used to customize each field in data class, different parameter that can be passed to field are defaultfactory, compare, hash, init, you can check about them over here &#xA;from dataclasses import dataclass, field&#xA;from typing import List&#xA;&#xA;@dataclass()&#xA;class Batch:&#xA;    sku: int&#xA;    name: str&#xA;    qty: int = 0&#xA;    creator: List[str] = field(default_factory=function/mutable value)&#xA;&#xA;Immutable Data Class&#xA;we can also define our data class as immutable by setting frozen=True, which basically means we cannot assign value to the fields after creation&#xA;@dataclass(frozen=True)&#xA;class Batch:&#xA;    sku: int&#xA;    name: str&#xA;    qty: int = 0&#xA;&#xA;      b = Batch(12, &#39;desk&#39;, 100)&#xA;      b.qty &#xA;100&#xA;      b.qty = 90&#xA;dataclasses.FrozenInstanceError: cannot assign to field &#39;qty&#39;&#xA;Data class saves us from writing boilerplate code, help us to focus on logic, this new feature of Python3.7 is great, so what waiting for go and right some data classes.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Python&#xA;DataClass&#xA;TIL&#xA;DGPLUG&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>A data class is a class containing data only, from Python3.7 we can define a data class with the help of decorator <code>@dataclass</code>, which build the class with the basic functionality like <code>__init__</code> , <code>__repr__</code>, <code>__eq__</code> and more special methods.</p>

<p>Let see how to define your data class with the decorator <code>@dataclass</code></p>

<pre><code class="language-python">from dataclasses import dataclass

@dataclass
class Batch:
    sku: int
    name: str
    qty: int

&gt;&gt;&gt; Batch(1, &#39;desk&#39;, 100)
Batch(sku=1, name=&#39;desk&#39;, qty=100)
</code></pre>

<p>We can also add the default value to the data class, which works exactly as if we do in the <code>__init__</code>  method of regular class. As you have noticed in the above we have defined the fields with type hints, which is kind of mandatory thing in the data class, if you do not do it will not take the field in your data class.</p>

<pre><code class="language-python">@dataclass
class Batch:
    sku: int = 1
    name: str = &#39;desk&#39;
    qty: int = 100

# if you don&#39;t want to explicity type the fields you can use any
from typing import Any
class AnyBatch:
    sku: Any
    name: Any = &#39;desk&#39;
    qty: Any = 100

</code></pre>

<p>If you want to define mutable default value in data class, it can be done with the help of <code>default_factory</code> and <code>field</code>. Field() is used to customize each field in data class, different parameter that can be passed to field are <code>default_factory</code>, <code>compare</code>, <code>hash</code>, <code>init</code>, you can check about them over <a href="https://docs.python.org/3/library/dataclasses.html#dataclasses.field" rel="nofollow">here </a></p>

<pre><code class="language-python">from dataclasses import dataclass, field
from typing import List

@dataclass()
class Batch:
    sku: int
    name: str
    qty: int = 0
    creator: List[str] = field(default_factory=&lt;function/mutable value&gt;)
</code></pre>

<p><strong>Immutable Data Class</strong>
we can also define our data class as immutable by setting <code>frozen=True</code>, which basically means we cannot assign value to the fields after creation</p>

<pre><code class="language-python">@dataclass(frozen=True)
class Batch:
    sku: int
    name: str
    qty: int = 0

&gt;&gt;&gt; b = Batch(12, &#39;desk&#39;, 100)
&gt;&gt;&gt; b.qty 
100
&gt;&gt;&gt; b.qty = 90
dataclasses.FrozenInstanceError: cannot assign to field &#39;qty&#39;
</code></pre>

<p>Data class saves us from writing boilerplate code, help us to focus on logic, this new feature of Python3.7 is great, so what waiting for go and right some data classes.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Python</span></a>
<a href="/sandeepk/tag:DataClass" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">DataClass</span></a>
<a href="/sandeepk/tag:TIL" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">TIL</span></a>
<a href="/sandeepk/tag:DGPLUG" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">DGPLUG</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/python-data-class</guid>
      <pubDate>Fri, 03 Sep 2021 12:54:52 +0000</pubDate>
    </item>
    <item>
      <title>Ansible: Roles</title>
      <link>https://blogs.dgplug.org/sandeepk/ansible-roles</link>
      <description>&lt;![CDATA[Ansible&#39;s roles allow grouping the content, which can be reused and easily share with other users. The role consists of vars, files, tasks, and other artifacts in a standard directory structure which have these subdirectories.&#xA;&#xA;Tasks&#xA;Handlers&#xA;Library&#xA;Default&#xA;Vars&#xA;Files&#xA;Templates&#xA;Meta&#xA;&#xA;We can use roles in the playbook or task with the help of Include and Import. To know more about Import/Include, you can check here&#xA;&#xA;At Playbook level with the At task level with At task level with &#xA;Playbook&#xA;Roles at playbook level are imported statically and executes the playbook in this order&#xA;&#xA;Pre tasks&#xA;Roles listed in the playbook&#xA;Tasks define in the playbook and any handler triggered by the tasks&#xA;Post tasks define after the role&#xA; &#xA;---&#xA;hosts: webservers&#xA;  roles:&#xA;    aws&#xA;&#xA;Task with Include&#xA;---&#xA;hosts: all&#xA;  tasks:&#xA;    name: Use a dynamic roles&#xA;       includeroles:&#xA;           name: rolename  &#xA;Task with Import&#xA;---&#xA;hosts: all&#xA;  tasks:&#xA;    name: Use a static roles&#xA;       importrole:&#xA;           name: rolename  &#xA;&#xA;Passing parameter to the roles&#xA;---&#xA;hosts: all&#xA;  roles:&#xA;    { role: aws, message: &#34;ec2&#34; }&#xA;    { role: aws, message: &#34;s3&#34; }&#xA;&#xA;Conditionally adding roles&#xA;---&#xA;hosts: all&#xA;  tasks:&#xA;    name: Include the somerole role&#xA;      includerole:&#xA;        name: somerole&#xA;      when: &#34;ansiblefacts[&#39;os_family&#39;] == &#39;Ubuntu&#39;&#34;&#xA; &#xA;Ansible&#39;s roles are really helpful to group the similar content and use in the different playbook and give the feasibility to the user to share with other which saves a lot of work. It&#39;s worth using them and shares your roles in the community to help others.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Ansible]]&gt;</description>
      <content:encoded><![CDATA[<p>Ansible&#39;s roles allow grouping the content, which can be reused and easily share with other users. The role consists of vars, files, tasks, and other artifacts in a standard directory structure which have these subdirectories.</p>
<ul><li>Tasks</li>
<li>Handlers</li>
<li>Library</li>
<li>Default</li>
<li>Vars</li>
<li>Files</li>
<li>Templates</li>
<li>Meta</li></ul>

<p>We can use roles in the playbook or task with the help of Include and Import. To know more about Import/Include, you can check <a href="https://blogs.dgplug.org/sandeepk/ansible-import-and-include" rel="nofollow">here</a></p>
<ul><li>At Playbook level with the <code>roles</code></li>
<li>At task level with <code>include_roles</code></li>
<li>At task level with <code>import_roles</code></li></ul>

<p><strong>Playbook</strong>
Roles at playbook level are imported statically and executes the playbook in this order</p>
<ul><li>Pre tasks</li>
<li>Roles listed in the playbook</li>
<li>Tasks define in the playbook and any handler triggered by the tasks</li>
<li>Post tasks define after the role</li></ul>

<pre><code class="language-yml">---
- hosts: webservers
  roles:
    - aws
</code></pre>

<p><strong>Task with Include</strong></p>

<pre><code class="language-yml">---
- hosts: all
  tasks:
    - name: Use a dynamic roles
       include_roles:
           name: role_name  
</code></pre>

<p><strong>Task with Import</strong></p>

<pre><code class="language-yml">---
- hosts: all
  tasks:
    - name: Use a static roles
       import_role:
           name: role_name  
</code></pre>

<p><strong>Passing parameter to the roles</strong></p>

<pre><code class="language-yml">---
- hosts: all
  roles:
    - { role: aws, message: &#34;ec2&#34; }
    - { role: aws, message: &#34;s3&#34; }
</code></pre>

<p><strong>Conditionally adding roles</strong></p>

<pre><code class="language-yml">---
- hosts: all
  tasks:
    - name: Include the some_role role
      include_role:
        name: some_role
      when: &#34;ansible_facts[&#39;os_family&#39;] == &#39;Ubuntu&#39;&#34;
</code></pre>

<p>Ansible&#39;s roles are really helpful to group the similar content and use in the different playbook and give the feasibility to the user to share with other which saves a lot of work. It&#39;s worth using them and shares your roles in the community to help others.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Ansible" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ansible</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/ansible-roles</guid>
      <pubDate>Wed, 01 Sep 2021 05:16:22 +0000</pubDate>
    </item>
    <item>
      <title>Ansible: Import &amp; Include</title>
      <link>https://blogs.dgplug.org/sandeepk/ansible-import-and-include</link>
      <description>&lt;![CDATA[In Ansible playbooks are a collection of different tasks. It&#39;s a good idea to break the tasks into the different files, which make it easier to include/import these task in different playbooks. Now the question is when to use include or import and how these two are different from each other?&#xA;&#xA;Ansible provides four distributed&#xA;Variables&#xA;Task&#xA;Playbook&#xA;Role&#xA;&#xA;Include&#xA;&#xA;Including variables, tasks, or role adds them into the playbook dynamically. This means when Ansible processes these files as they come up they are included in the current playbook as its variable, task, or role. So, these can be affected by the previous tasks.&#xA;&#xA;Playbook&#39;s can not be used with the include&#xA;&#xA;Import&#xA;&#xA;Importing task, playbook, or role add them into playbook statically. Ansible pre-processes these files before it runs any task in the playbook, which means these are not affected by other tasks.&#xA;&#xA;Tip: Import variables if you want to use these more than once in the playbook.&#xA;&#xA;Import and Include differ with the way Ansible loads these files into the playbook. So, it is good to use the one which best fits your use case.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Ansible]]&gt;</description>
      <content:encoded><![CDATA[<p>In Ansible playbooks are a collection of different tasks. It&#39;s a good idea to break the tasks into the different files, which make it easier to include/import these task in different playbooks. Now the question is when to use <em>include</em> or <em>import</em> and how these two are different from each other?</p>

<p>Ansible provides four distributed
– Variables
– Task
– Playbook
– Role</p>

<p><strong>Include</strong></p>

<p>Including variables, tasks, or role adds them into the playbook <strong>dynamically</strong>. This means when Ansible processes these files as they come up they are included in the current playbook as its variable, task, or role. So, these can be affected by the previous tasks.</p>

<p><em>Playbook&#39;s can not be used with the include</em></p>

<p><strong>Import</strong></p>

<p>Importing task, playbook, or role add them into playbook <strong>statically</strong>. Ansible pre-processes these files before it runs any task in the playbook, which means these are not affected by other tasks.</p>

<p>Tip: Import variables if you want to use these more than once in the playbook.</p>

<p>Import and Include differ with the way Ansible loads these files into the playbook. So, it is good to use the one which best fits your use case.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Ansible" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ansible</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/ansible-import-and-include</guid>
      <pubDate>Mon, 30 Aug 2021 05:26:54 +0000</pubDate>
    </item>
    <item>
      <title>Ansible: Error Handling</title>
      <link>https://blogs.dgplug.org/sandeepk/ansible-error-handling</link>
      <description>&lt;![CDATA[Ansible stops executing on the host whenever it receives a non-zero return code from a command. We can handle these situations with the helps of settings and tools to behave as it we want.&#xA;&#xA;Ignoring Errors&#xA;Ansible stops executing commands on the host when it receives non-zero code, but we can ignore these errors and run the rest of the tasks as it is.&#xA;name: I will cause an error&#xA;  ...configs&#xA;  ignoreerrors: yes&#xA;&#xA;Failed when&#xA;Ansible let you define the condition when you want explicitly fail when a certain condition is true.&#xA;name: Fail task under certain condition true&#xA;  command: ls/tmp/dirnotexist&#xA;  register: result&#xA;  failedwhen: result.rc == 0&#xA;&#xA;Aborting on first error&#xA;anyerrorsfatal finishes the  fatal task on all hosts in the current batch, then stops executing on all hosts.&#xA;hosts: somehosts&#xA;  anyerrorsfatal: true&#xA;  tasks:&#xA;    block:&#xA;         includetasks: sometask.yml&#xA;Handling errors with blocks&#xA;Ansible let you control errors in a block with rescue and always section. In rescue, we can define tasks which we want to run when an earlier task in a block fails. You can also think of rescue as except  and always as finally in other languages to handle errors.&#xA;task:&#xA;name: tasks to be run&#xA;  block:&#xA;     name: task 1&#xA;       // code&#xA;     name: task 2&#xA;       // code&#xA;     name: task 3&#xA;       // code&#xA;rescue:&#xA;     name: Run when one of the above task fails&#xA;       // code&#xA;always:&#xA;     name: Always run &#xA;       // code&#xA;&#xA;Ansible provide ignore, rescue, always, failedwhen to easily handle the behavior of playbook when we face any errors. We can use these commands/settings to gracefully record errors and take specific action.&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Ansible&#xA;&#xA;   &#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Ansible stops executing on the host whenever it receives a non-zero return code from a command. We can handle these situations with the helps of settings and tools to behave as it we want.</p>

<p><strong>Ignoring Errors</strong>
Ansible stops executing commands on the host when it receives non-zero code, but we can ignore these errors and run the rest of the tasks as it is.</p>

<pre><code class="language-yml">- name: I will cause an error
  ...configs
  ignore_errors: yes
</code></pre>

<p><strong>Failed when</strong>
Ansible let you define the condition when you want explicitly fail when a certain condition is true.</p>

<pre><code class="language-yml">- name: Fail task under certain condition true
  command: ls/tmp/dir_not_exist
  register: result
  failed_when: result.rc == 0
</code></pre>

<p><strong>Aborting on first error</strong>
<em>any<em>errors</em>fatal</em> finishes the  fatal task on all hosts in the current batch, then stops executing on all hosts.</p>

<pre><code class="language-yml">- hosts: somehosts
  any_errors_fatal: true
  tasks:
    - block:
         - include_tasks: sometask.yml
</code></pre>

<p><strong>Handling errors with blocks</strong>
Ansible let you control errors in a block with rescue and always section. In rescue, we can define tasks which we want to run when an earlier task in a block fails. You can also think of rescue as except  and always as finally in other languages to handle errors.</p>

<pre><code class="language-yml">task:
- name: tasks to be run
  block:
     - name: task 1
       // code
     - name: task 2
       // code
     - name: task 3
       // code
rescue:
     - name: Run when one of the above task fails
       // code
always:
     - name: Always run 
       // code
</code></pre>

<p>Ansible provide <em>ignore</em>, <em>rescue</em>, <em>always</em>, <em>failed_when</em> to easily handle the behavior of playbook when we face any errors. We can use these commands/settings to gracefully record errors and take specific action.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Ansible" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ansible</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/ansible-error-handling</guid>
      <pubDate>Fri, 27 Aug 2021 05:31:47 +0000</pubDate>
    </item>
    <item>
      <title>Ansible: Tags</title>
      <link>https://blogs.dgplug.org/sandeepk/ansible-tags</link>
      <description>&lt;![CDATA[Ansible&#39;s tags are helpful to run a specific part of the playbook, rather running the whole playbook. Using tags, you can run or skip the tasks.&#xA;&#xA;Tags can be added to one task or multiple tasks or role, block etc. Let see how to do that&#xA;&#xA;Adding tags to a task&#xA;&#xA;  tasks:&#xA;  name: Assign the var&#xA;    apt:&#xA;      name: apache2&#xA;      state: latest&#xA;    tags:&#xA;      vars&#xA;  name: Enable and run httpd&#xA;    apt:&#xA;      name: httpd&#xA;      state: started&#xA;      enabled: &#39;yes&#39;&#xA;    tags:&#xA;      httpd&#xA;      vars&#xA;Adding tags to role&#xA;roles:&#xA;  role: config&#xA;    vars:&#xA;      port: 8003&#xA;    tags: [ web, flask ]&#xA;&#xA;Adding tags to block&#xA;All the tasks in the block will share the same tag&#39;s &#xA;tasks:&#xA;name: git tasks&#xA;  tags: git&#xA;  block:&#xA;  name: install apache&#xA;    apt:&#xA;      name: git&#xA;      state: latest&#xA;&#xA;Special tags&#xA;Ansible have two special tags, never and always. If you add always tag to task, play, Ansible will always run the task or play, unless explicitly asked to skip with the help of (--skip-tags always)&#xA;&#xA;On the other hand, never tag if assign to a task or play, Ansible will skip that task or play unless you explicitly asked it (--tags never).&#xA;&#xA;Running the Playbook with tags&#xA;&#xA;will run tasks with tag git : &#xA;will not run tasks with tag git : &#xA;list all the tags : &#xA;run all tasks, ignore tags (default behavior):  &#xA;run only tasks with either the tag tag1 or the tag tag2: &#xA;run all tasks, except those with either the tag tag3 or the tag tag4: &#xA;&#xA;run only tasks with at least one tag: &#xA;run only tasks with no tags:  &#xA;&#xA;That&#39;s all about the Ansible tags. Now go and tag your tasks :).&#xA;&#xA;Cheers!&#xA;&#xA;100DaysToOffload&#xA;Ansible&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Ansible&#39;s tags are helpful to run a specific part of the playbook, rather running the whole playbook. Using tags, you can run or skip the tasks.</p>

<p>Tags can be added to one task or multiple tasks or role, block etc. Let see how to do that</p>

<p><strong>Adding tags to a task</strong></p>

<pre><code class="language-yml">  tasks:
  - name: Assign the var
    apt:
      name: apache2
      state: latest
    tags:
      - vars
  - name: Enable and run httpd
    apt:
      name: httpd
      state: started
      enabled: &#39;yes&#39;
    tags:
      - httpd
      - vars
</code></pre>

<p><strong>Adding tags to role</strong></p>

<pre><code class="language-yml">roles:
  - role: config
    vars:
      port: 8003
    tags: [ web, flask ]
</code></pre>

<p><strong>Adding tags to block</strong>
All the tasks in the block will share the same tag&#39;s</p>

<pre><code class="language-yml">tasks:
- name: git tasks
  tags: git
  block:
  - name: install apache
    apt:
      name: git
      state: latest
</code></pre>

<p><strong>Special tags</strong>
Ansible have two special tags, <em>never</em> and <em>always</em>. If you add always tag to task, play, Ansible will always run the task or play, unless explicitly asked to skip with the help of (—skip-tags always)</p>

<p>On the other hand, <em>never</em> tag if assign to a task or play, Ansible will skip that task or play unless you explicitly asked it (—tags never).</p>

<p><strong>Running the Playbook with tags</strong></p>
<ul><li><p>will run tasks with tag <em>git</em> : <code>ansible-playbook example.yml --tags &#34;git&#34;</code></p></li>

<li><p>will not run tasks with tag <em>git</em> : <code>ansible-playbook example.yml --skip-tags &#34;git&#34;</code></p></li>

<li><p>list all the tags : <code>ansible-playbook example.yml --list-tags</code></p></li>

<li><p>run all tasks, ignore tags (default behavior):  <code>--tags all</code></p></li>

<li><p>run only tasks with either the tag tag1 or the tag tag2: <code>--tags [tag1, tag2]</code></p></li>

<li><p>run all tasks, except those with either the tag tag3 or the tag tag4:
<code>--skip-tags [tag3, tag4]</code></p></li>

<li><p>run only tasks with at least one tag: <code>--tags tagged</code></p></li>

<li><p>run only tasks with no tags:  <code>--tags untagged</code></p></li></ul>

<p>That&#39;s all about the Ansible tags. Now go and tag your tasks :).</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>
<a href="/sandeepk/tag:Ansible" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Ansible</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/ansible-tags</guid>
      <pubDate>Sat, 14 Aug 2021 06:07:09 +0000</pubDate>
    </item>
  </channel>
</rss>