<?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[opensight.ch - Medium]]></title>
        <description><![CDATA[We blog about digital transformation, cloud, devops and open source. You can visit our homepage at en.opensight.ch - Medium]]></description>
        <link>https://medium.com/opensight-ch?source=rss----d8d441ca6b25---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>opensight.ch - Medium</title>
            <link>https://medium.com/opensight-ch?source=rss----d8d441ca6b25---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 11:43:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/opensight-ch" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PRTG Monitoring — Intune App Installation States]]></title>
            <link>https://medium.com/opensight-ch/prtg-monitoring-intune-app-installation-states-c34b2e9a5cb8?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/c34b2e9a5cb8</guid>
            <category><![CDATA[tunein]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[prtg]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Sat, 18 Mar 2023 08:53:50 GMT</pubDate>
            <atom:updated>2023-03-18T08:53:50.553Z</atom:updated>
            <content:encoded><![CDATA[<h4>How you can use PRTG to monitor your intune apps and their rollout status on your intune managed devices</h4><p>How you can use PRTG to monitor your intune apps and their rollout status (device states)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xxBV71xpJbJ_ZG5B.png" /><figcaption>Image — Software Device Status in Intune / Microsoft Endpoint Manager</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*05GZz14wQVaF8TPV.png" /><figcaption>Image — PRTG Monitoring of 7zip App Rollout Status</figcaption></figure><p><a href="https://opensight.ch/produkt/prtg-sensor-monitoring-intune-app-installation-state/">Sensor Download</a></p><p>When you rollout an application with microsoft intune you might wanna use your existing monitoring to have an overview of the rollout states, in order to see, whether your installations run well on the devices. One option is to use PRTG Monitoring for Endpoint Manager (Intune).</p><p>With the management of the work devices by Microsoft Endpoint Manager (Intune), there is also the possibility of having endpoint manager information in your existing PRTG monitoring.</p><p>To monitor the indicators, we use monitoring software from Paessler. <a href="https://www.paessler.com/prtg?ref=opensight-ch">PRTG</a> monitors data traffic, availability and performance of devices and applications in IT infrastructures. This includes monitoring for classic network devices such as servers, routers, switches and firewalls, as well as virtual environments and also — as in this example — you can use the right scripts to monitor cloud components such as Microsoft Endpoint Manager.</p><p>In this example, we would like to measure the following Microsoft Endpoint Manager indicators with PRTG:</p><ul><li><strong>Overall — Installation State</strong><br>Installation State of “all apps” / overall on the devices. According to the documentation, the state can be one of the following:<br><em>“installed”, “failed”, “notInstalled”, “uninstallFailed”, “pendingInstall”, “unknown”, “notApplicable”. </em><br>Our script allows to filter the states you desire to measure in PRTG and also a “total” by spefifying the script parameter “-states” (examples below)</li><li><strong>By Product — Installation State</strong><br>Measure the Installation state of specific Apps with PRTG. Our Script allows to filter out Apps by the script parameter “-softwarenames”. The parameter also allows to use “all” to show all detected apps from intune or “overall” to show the status over all apps in total. (examples / use cases below)</li></ul><p>So let’s now check some usecases.</p><h4>Use Cases</h4><p><strong>Rollout Status of specific App — 7zip</strong></p><p>In order to show the rollout state of the specific app we can use the following parameters:</p><pre>v1_prtg_intune_app_status.ps1 -states &#39;total;installed;failed;pendingInstall;unknown;notApplicable&#39; -softwarenames &#39;7zip 22&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mfjzY_9qOC8Q1wI2.png" /><figcaption>Image — Intune Appstate PRTG Sensor 7zip Rolloutstate</figcaption></figure><p>We could also show several or even all software by specifying multiple software names (-softwarenames ‘7zip 22;winscp’) or just (-softwarenames ‘all’).</p><p><strong>Installation Status Overall</strong></p><p>Lets Check the installation Status of all software packages overall. In our test environment we have 2 software packages assigned to 2 devices. Like you can see on the screenshot below, we have therefore 4 “installed” states in total so everything is fine. This was achieved with the following script parameters:</p><pre>v1_prtg_intune_app_status.ps1 -states &#39;installed;failed;total;pendingInstall;unknown;notApplicable&#39; -softwarenames &#39;overall&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AA1l2SFVPGotwRzj.png" /><figcaption>Image — Intune Appstate PRTG Sensor overall Rolloutstate</figcaption></figure><p><strong>Show all failed Installations</strong></p><p>Finally — Lets do a dashboard for all failed installations so you get the drift for the script parameters. New apps in intune will appear automatically because we specified -softwarenames ‘all’:</p><pre>v1_prtg_intune_app_status.ps1 -states &#39;failed&#39; -softwarenames &#39;all&#39;</pre><p>Unfortunately, there’s not much to see because we have no failed installs right now for our packages “winscp” and “7zip 22”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iPotCENjeEHo06_m.png" /></figure><p><strong>Hail Mary — Just for fun</strong></p><p>Ok — just for fun one more that just shows just everything. Even though we have just 2 packages in the test environment it can get crowded.</p><pre>v1_prtg_intune_app_status.ps1 -states &#39;all&#39; -softwarenames &#39;all;overall&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mu3AkF4i5ywffnIC.png" /></figure><h4><strong>Prerequisites</strong></h4><p>A Service Principal (app registration) is required in Azure AD in order to be able to read out the desired indicators. This must have the appropriate read permissions in the Microsoft Graph API.<br><a href="https://docs.microsoft.com/de-de/azure/role-based-access-control/built-in-roles?ref=opensight-ch#reader">https://learn.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals</a></p><p>The Powershell module «MSAL.PS» is installed on the PRTG server or the PRTG probe. It is the Microsoft Authentication Library module, which is required so that the script can retrieve an access token.</p><p>Install-Module MSAL.PS -Scope AllUsers -Force</p><p>Powershell — Install MSAL Library (Microsoft Authentication Library)</p><p>The script uses this library at one point to get an access token:</p><p># acquire azure authentication token $MsalToken = Get-MsalToken -TenantId $tenant_id -ClientId $app_id -ClientSecret ($client_secret | ConvertTo-SecureString -AsPlainText -Force) #Connect to Graph using access token Connect-Graph -AccessToken $MsalToken.AccessToken</p><p>powershell — acquire azure authentication token</p><p>If an error message appears, NuGet cannot be installed, TLS 1.2 must first be enforced on the probe, where the script of the sensr will run.</p><p>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Install-PackageProvider NuGet</p><p>powershell — enforce tls 1.2</p><h4><strong>service principal (app registraion)</strong></h4><p>Now a “Service Principal” (app registration) including Secret must be created in Azure Active Directory. During this process you will receive various information, which you then need to run the monitoring script so that it can access the information in Azure:</p><ul><li>application id (app_id)</li><li>azure tenant id (tenant_id)</li><li>application client secret (client_secret)</li></ul><p>The creation of the Service Principal is described in detail in the download (readme).</p><h4><strong>Powershell Graph API</strong></h4><p>The desired Endpoint Manager indicators are provided by Microsoft via the Graph API. In the past, each product had its own API or even multiple APIs. Exchange knows EWS, REST, ActiveSync and MAPI/HTTP, Skype for Business has a UCWA and a UCMA and so the story can be told endlessly. Each API has its own URL, methods and format, and authentication mechanisms.</p><p>With Microsoft Graph, Microsoft wants to provide uniform access to all data via a REST interface. Our script will use the following endpoint:</p><pre><a href="https://graph.microsoft.com/V1.0/deviceManagement/managedDevices">https://graph.microsoft.com/V1.0/deviceManagement/managedDevices</a></pre><p>This is documented in more detail <a href="https://learn.microsoft.com/en-us/graph/api/intune-devices-manageddevice-list?view=graph-rest-1.0&amp;ref=opensight-ch">here</a> at Microsoft.</p><h4><strong>PRTG Configuration</strong></h4><h4>Create Sensor</h4><ul><li>Create a new <a href="https://www.paessler.com/manuals/prtg/exe_script_advanced_sensor?ref=opensight-ch">EXE/Script Advanced</a> sensor for the probe, where our custom exexml script is installed.</li><li>Select “Powershell Script — v1_prtg_intune_app_status.ps1” for the script selection.</li><li>Fill in the parameter field:<br>-app_id ‘&lt;%azure_application_id&gt;’<br>-tenant_id ‘&lt;%azure_tenant_id&gt;’<br>-client_secret ‘&lt;%azure_application_client_secret&gt;’<br>-states ‘all’<br>-softwarenames ‘all;overall’</li><li>Increase timeout from 60s to 120s.</li><li>Configure the interval to suit your needs, e.g. once every hour.</li></ul><p>The alerts are individual, so the desired thresholds should be defined in the channel settings under Value Lookups and Limits. <a href="https://www.paessler.com/manuals/prtg/sensor_channels_settings?ref=opensight-ch">https://www.paessler.com/manuals/prtg/sensor_channels_settings</a></p><p>Important Microsoft Endpoint Manager information is displayed in the monitoring with little effort and an alarm is triggered by email, ticket, Microsoft Teams, etc. when a defined threshold value is exceeded.</p><p><a href="https://opensight.ch/produkt/prtg-sensor-monitoring-intune-app-installation-state/">Sensor Download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c34b2e9a5cb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/prtg-monitoring-intune-app-installation-states-c34b2e9a5cb8">PRTG Monitoring — Intune App Installation States</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event-Driven Architecture with Ansible and Kafka]]></title>
            <link>https://medium.com/opensight-ch/event-driven-architecture-with-ansible-and-kafka-108cf70c5c05?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/108cf70c5c05</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[digitalisation]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Mon, 13 Feb 2023 18:58:47 GMT</pubDate>
            <atom:updated>2023-03-18T08:11:46.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uX2cD5Ak2Eo1tl2w.jpg" /></figure><blockquote>With an event-driven architecture, you can create a symbiosis between human actors and systems in the company and massively reduce the throughput time of your work in general. Modern businesses often use many different IT-Systems and Services — complexity therefore increases and you have to create and manage more and more API-Interfaces and interconnections — <strong>spaghetti infrastructure</strong>. So why not introduce a central event streaming service — a message bus / event-driven-architecture in order to enable easier integration of different systems and services into each other, allowing for a more flexible system that is easier to adapt to changing business needs.</blockquote><blockquote>opensight.ch — roman huesler</blockquote><p>Today we will use our existing instance of apache kafka (a message bus), on which we will send an event / message that will be picked up by “Event Driven Ansible” in order to perform infrastructure automation tasks. Ansible can then run a playbook that would — as an example — provision a server or do any business task you can imagine…</p><p>Red Hat has developed Event-Driven Ansible technology to enhance and expand automation, increasing IT speed and agility while providing consistency and resilience. Today, we are offering a developer preview of this technology.</p><p><a href="https://github.com/butschi84/event-driven-ansible">Blog Post GIT Repository</a></p><p><a href="https://www.ansible.com/use-cases/event-driven-automation">Redhat — EDA Page</a></p><h4>Event Driven Ansible</h4><p>Ansible is an automation tool (open source) that combines functions such as software distribution, ad hoc command execution and configuration management. Normally, ansible follows a pushed-based model where playbook runs are initiated manually or by a schedule. With “Event Driven Ansible” you run actions according to hooks and predefined conditions. This could potentially eliminate a lot of manual tasks.</p><p>The Ansible system uses files in YAML format (playbooks) to describe the desired status of systems. The Ansible “master server” then connects to the “slave servers” (or WinRM in the case of Windows) via SSH in order to carry out the necessary configurations. There are numerous out-of-the-box “Ansible modules” with which you can carry out all sorts of system configurations.</p><p><strong>Rulebooks, Rules, Conditions, Actions</strong></p><p>So in Ansible you have your Playbooks, whereas in event driven ansible (EDA) you write a “rulebook”. In the rulebook, you can define some rules (<a href="https://ansible-rulebook.readthedocs.io/en/latest/rules.html">documentation</a>), hooks, alertmanagers, urls, files to listen to and then define rules to launch your playbooks accordingly. Also conditions can be defined.</p><p>Conditions (<a href="https://ansible-rulebook.readthedocs.io/en/latest/conditions.html">documentation</a>) can be a triggered alert from the Alertmanager or an unreachable website, a newly created file or just a message that was received from the webook.</p><p>So here is our Example Rulebook that we use today. It hooks to events on the kafka topic (“kafka-test-topic”) and can also receive events over port 8080.</p><p>What happens when a condition is triggered is defined in an action (<a href="https://ansible-rulebook.readthedocs.io/en/latest/actions.html">documentation</a>). Most of the time “<a href="https://ansible-rulebook.readthedocs.io/en/latest/actions.html#run-playbook">run_playbook</a>” should fit your needs but you can check a list of other actions in the documentation. The message payload from the kafka message will be passed on to the playbook automatically (“event.message”).</p><pre>---<br>- name: Listen for events on kafka<br>  hosts: all<br> <br>  sources:<br>    - ansible.eda.kafka:<br>        host: kafka-0.kafka-headless.kafka.svc.cluster.local<br>        port: 9092<br>        topic: kafka-test-topic<br>        group_id: ansible-eda<br>    - ansible.eda.webhook:<br>        host: 0.0.0.0<br>        port: 8080<br> <br>  rules:<br>    - name: kafka<br>      condition: event.message != &quot;&quot;<br>      action:<br>        run_playbook:<br>          name: do-something.yml<br>    - name: webhook<br>      condition: event.payload.message != &quot;&quot;<br>      action:<br>        run_playbook:<br>          name: do-something.yml<br>          var_root: payload</pre><h4>Installation</h4><p>We will use:</p><ul><li>Prereq — Apache Kafka (message bus) on Kubernetes</li><li>Prereq — Kafka UI on Kubernetes</li><li>Event Driven Ansible on Kubernetes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/0*iQ1HZLMGOIHZJpDo.png" /><figcaption><em>Image — Test Setup for Event Driven Ansible</em></figcaption></figure><p>What Ansible AWX is for Ansible, the <a href="https://github.com/ansible/eda-server#event-driven-ansible-server">Event Driven Ansible Server</a> is for the Ansible-Rulebook. We will use our Kubernetes Cluster to run an Event Driven Ansible (EDA) server and therefore generate a docker image. We already have a running kafka instance on our kubernetes. Also we have a running instance of “Kafka UI” so we are able to fire events with a GUI. We use the following dockerfile to generate the EDA-Image and then start it on the kubernetes cluster.</p><p><strong>Dockerfile</strong> — Event Driven Ansible</p><pre>FROM ubuntu:latest<br><br>RUN apt update &amp;&amp; apt install -y build-essential maven openjdk-17-jdk python3-dev python3-pip<br>ENV JDK_HOME=/usr/lib/jvm/java-17-openjdk-amd64<br>ENV JAVA_HOME=$JDK_HOME<br>ENV PIP_NO_BINARY=jpy<br>ENV PATH=$PATH:~/.local/bin<br>RUN python3 -m pip install -U Jinja2<br>RUN python3 -m pip install aiokafka<br>RUN python3 -m pip install ansible ansible-rulebook ansible-runner wheel<br>RUN ansible-galaxy collection install community.general ansible.eda<br>RUN apt install vim curl -y<br><br>COPY *.yml ./<br>COPY webhook-rule.yml ./<br><br>EXPOSE 8080/tcp<br>CMD [&quot;ansible-rulebook&quot;, &quot;--rulebook&quot;, &quot;webhook-rule.yml&quot;, &quot;-i&quot;, &quot;inventory.yml&quot;, &quot;--verbose&quot;]</pre><p>Once the rule executes we start a playbook “do-something.yml”</p><p><strong>Playbook</strong> — do-something.yml</p><pre>- hosts: all<br>  connection: local<br>  tasks:<br>    - debug:<br>        msg: &quot;you have send the following message:&quot;<br>    - debug:<br>        var: event.message</pre><p>Check our GIT Repository (Link on the top) in order to have an overview of all the files.</p><h4>Practice Test</h4><p>We see the Event-Driven-Ansible Pod is now started and reeady on our kubernetes. It is hooked to the kafka message bus topic “kafka-test-topic”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ubO2UE1kqezIuAsn.png" /><figcaption><em>Image — Event Driven Ansible Server Running on Kubernetes</em></figcaption></figure><p>So lets send a message to the kafka message bus by using our Kafka UI container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NTvgfu1Cgce2Xvh6.png" /><figcaption><em>Image — Sending a Message to Kafka Message Bus using Kafka UI</em></figcaption></figure><p>Immediately the event driven ansible server picked up the event and executed the playbook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p9qn0Z6ZuFU2ueEK.png" /><figcaption><em>Image — Event Driven Ansible Picking up Kafka Message and Executing Playbook</em></figcaption></figure><p>If you dont have a running kafka instance, you can also forward the port 8080 from the running pod on kubernetes to your local machine and then send a message to the webhook of EDA that we defined earlier:</p><pre>curl -H &#39;Content-Type: application/json&#39; -d &quot;{\&quot;message\&quot;: \&quot;hello from commandlinel\&quot;}&quot; <a href="http://127.0.0.1:8080/endpoint">http://127.0.0.1:8080/endpoint</a></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=108cf70c5c05" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/event-driven-architecture-with-ansible-and-kafka-108cf70c5c05">Event-Driven Architecture with Ansible and Kafka</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intune and Chocolatey, Dream Team for Deployment]]></title>
            <link>https://medium.com/opensight-ch/intune-and-chocolatey-dream-team-for-deployment-b067f0d243c4?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/b067f0d243c4</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[tunein]]></category>
            <category><![CDATA[chocolatey]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[client-management]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Wed, 19 Oct 2022 12:33:40 GMT</pubDate>
            <atom:updated>2022-10-19T13:43:50.459Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X7trtMOwm4-7oQU5.jpg" /></figure><p>In this blog series we look at how you can use a combination of Intune, Chocolatey and some tools (which can also be operated via the command line) to act very quickly and productively with the deployment of software packages.</p><blockquote>With Chocolatey and Intune you are lightning fast in package deployment, especially if you manage several different Intune customer environments that require the same software packages.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><p>This first part of the blog series is more about the theoretical part — showing why we think the combination of Intune and Chocolatey works well together and what Chocolatey is (in case you don’t already know it).</p><h4>Contents</h4><h4>Part 1 — Intune and Chocolatey, Dream Team for Deployment</h4><ul><li><a href="#vorteile">Benefits of Chocolatey</a></li><li><a href="#zusammenspiel">Interplay of Chocolatey and Intune</a></li><li><a href="#detection">Package Detection and Compliance</a></li><li><a href="#jumpstart">Chocolatey Jump Start</a></li><li><a href="#wrapup">Wrap up</a></li></ul><h4>Part 2 — Fast Chocolatey Package Creation</h4><ul><li>Chocolatey Packaging</li><li>Intunewin Packages</li></ul><h4>Part 3 — Private Package Repository</h4><ul><li>Setting up a private package repository</li><li>Configurations</li><li>Agent Configuration for use with private package repository</li></ul><h4>Benefits of Chocolatey</h4><p><a href="https://chocolatey.org/">Chocolatey</a> has become a very popular package manager for Windows. If you don’t know Chocolatey yet, here are a few advantages from our point of view</p><ul><li><strong>Uniform command line for installation / uninstallation</strong><br>Installation packages come in many formats and with many different parameters (setup.exe, installshield, msi, bare files, …). With a Chocolatey package (nupkg) you have a unified command line for installing and uninstalling packages. (“choco install &lt;packagename&gt;“)</li><li><strong>Transportable</strong><br>You can install Chocolatey packages (nupkg) either from a directory (“choco install -s c:\temp”) or from a package repository on the Internet with TLS encryption (choco source add -n mysource -s https:/ /myrepo.com/repository/public/). There is also the <a href="https://community.chocolatey.org/packages">public package repository</a> with hundreds of packages.</li><li><strong>package repository</strong><br>You can also create a private package repository on the internet using a NUPKG repository server (e.g. Sonatype Nexus). More on that later in this blog series.</li><li><strong>Just-in-time deployment</strong><br>If you distribute a package with Intune, this always involves waiting times. If, on the other hand, you use a combination of Intune and Chocolatey, you have the option of testing your packages manually on the client just in time. The interaction with the Intune Client Management Service works very well — as you will see later in this blog series (package detection script).</li></ul><h4>Interplay of Chocolatey and Intune</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ymKgTNfz-fnQK_UU.png" /><figcaption><em>Image — Interplay of Chocolatey and Intune</em></figcaption></figure><p>As an example, we take a device that is managed by Intune. A Chocolatey Agent is installed on the device. This is a <strong>passive agent</strong> — so it doesn’t do anything as long as it is not explicitly called. If we now want to install a software package with Intune, the Intune Service executes the installation command from the Intunewin package: “choco install &lt;packagename&gt; -y”. The Chocolatey Agent now becomes active and downloads the installation package from the configured repository (if necessary via https). Then the installation package will be executed.</p><blockquote>This is also a key advantage when managing different customer environments. You can use the synergies and connect the same package repository here. This saves you a lot of time.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><h4>Intune Package Detection Script and Compliance</h4><p>Chocolatey saves the installation files of the package under “c:\programdata\chocolatey\lib\&lt;packagename&gt;” after successful installation. Based on the existence of this folder, you can also easily determine whether a package is installed on the computer.</p><p>For each Microsoft Intune package you also have to configure “detection rules”. These determine whether a package may already be installed on the computer. You can guess: We simply check the existence of the folder: “c:\programdata\chocolatey\lib\&lt;packagename&gt;”. This means that even if you manually interact with the Chocolatey Agent (e.g. install packages), the Intune Service will determine that the package is already installed and will not run the installation again.</p><p>You can also make the Chocolatey Package Compliance / Detection / Intune Detection Script even more sophisticated. For example, if you want to determine whether at least package version “3.4.0” is installed, you can use a script based on the “choco list -lo” command. (This command lists all locally installed packages).</p><p>What we found out by the way — the detection scripts may (and must) generate exactly one line of standard output and then return a return code. Return code 0 in the detection script means that the device is compliant or the package is correctly installed.</p><pre># =======================================<br># functions<br># =======================================<br>function packageVersion($packageName) {<br>    $result = (c:\programdata\chocolatey\bin\choco.exe list -lo | Where-object { $_.ToLower().StartsWith($packageName.ToLower()) })<br>    <br>    if($result -ne $null){<br>        $parts = $result.Split(&#39; &#39;);<br>        $installedVersion = [version]$parts[1]<br>            <br>        write-host Installed Version is $installedVersion<br><br>	    return $installedVersion<br>    }else{<br>        return $null<br>    }<br>}<br><br><br># =======================================<br># MAIN<br># =======================================<br>$packageName = &quot;&lt;my_chocolatey_package_name&gt;&quot;<br>$installedVersion = packageVersion -packageName $packageName<br><br>if($installedVersion -ge [version]&quot;3.4.0&quot;) {<br>    # write-host $packageName version check =&gt; ok<br>    exit 0<br>}else{<br>    # write-host $packageName version check =&gt; not ok<br>    exit 1<br>}</pre><h4>Chocolatey Jump Start</h4><p>Would you like to try Chocolatey for yourself?<br>Set up a Windows VM and run this lab (10min).</p><p><strong>Chocolatey Installation</strong></p><p>Open a powershell as administrator and run the installation command according to the <a href="https://chocolatey.org/install">Chocolatey Documentation</a>. The command installs the passive agent under “c:\programdata\chocolatey” and creates an entry in the “PATH” variable.</p><pre>Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(&#39;https://community.chocolatey.org/install.ps1&#39;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NxalZCVAPWHeU868.png" /><figcaption><em>Image — Chocolatey Source list. Community Repository</em></figcaption></figure><p><strong>Repository Configuration</strong></p><p>You can see that the public community repository has been configured by default:</p><pre># list source repositories<br>choco source list<br><br># list available packages<br>choco list</pre><p><strong>Package Installation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xjJE6nYg19-1aOre.png" /></figure><p>Now let’s install a package from the public repository</p><pre>choco install cutepdf -y</pre><p>After a short wait, the software is already installed. You will also see under “c:\programdata\chocolatey\lib” that there is a folder called “cutePDF” with the installation files.</p><p>This contains the package “CutePDF.nupkg” in packed form. This can easily be unzipped with 7zip…</p><p><strong>Chocolatey Package Structure</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KKh4Sb5KEMynpnX0PJb0MQ.jpeg" /><figcaption>Image — Chocolatey Package Structure</figcaption></figure><p>Also included is the already unpacked package. So you can see what a Chocolatey package consists of:</p><p><strong>cutepdf.nuspec</strong><br>The Nuspec file contains the metadata of the package (version, package name, etc.).</p><p><strong>tools\chocolateyInstall.ps1</strong><br>A powershell script that is executed when installing the Chocolatey package.</p><p><strong>tools\chocolateyUninstall.ps1</strong><br>A powershell script that is executed when the Chocolatey package is uninstalled.</p><p>The setup files (MSI, EXE, etc.) can often also be found in the tools directory. In the case of CutePDF, however, you can see in the chocolateyInstall.ps1 script that the installation files are downloaded from the Internet directly during installation.</p><h4>Wrap Up — Intune and Chocolatey</h4><p>So much for the theoretical part. In the next parts of this blog series we will go into the technical details, create Chocolatey and Intunewin packages and create a private package repository with authentication and TLS encryption.</p><p>We would be happy if you follow our blog (also on <a href="https://medium.com/opensight-ch">medium.com</a>) and exchange ideas with us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b067f0d243c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/intune-and-chocolatey-dream-team-for-deployment-b067f0d243c4">Intune and Chocolatey, Dream Team for Deployment</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PRTG — Monitoring Intune (Graph API, Microsoft Endpoint Manager)]]></title>
            <link>https://medium.com/opensight-ch/prtg-monitoring-intune-graph-api-microsoft-endpoint-manager-d5b118e61106?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/d5b118e61106</guid>
            <category><![CDATA[endpoint-manager]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[tunein]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Sat, 24 Sep 2022 11:31:15 GMT</pubDate>
            <atom:updated>2022-10-19T07:00:34.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O8Lqho34B63LBxAC.jpg" /></figure><figure><img alt="PRTG Intune Endpoint Manager Sensor" src="https://cdn-images-1.medium.com/max/1024/0*6w01EdnFCPyXHUz3.png" /><figcaption><em>Image — PRTG Sensor Intune Devices</em></figcaption></figure><p>The current trend towards web-based software applications and services such as Microsoft 365 also reflects the need of employees and companies to be able to work more mobile or in the home office. With modern IT work devices that work location-independent, ensuring the compliance of these devices is particularly important.<br>One option is to use PRTG Monitoring for Endpoint Manager (Intune).</p><p>With the management of the work devices by Microsoft Endpoint Manager (Intune), there is also the possibility of having endpoint manager information in your existing PRTG monitoring.</p><p>To monitor the indicators, we use monitoring software from Paessler. <a href="https://www.paessler.com/prtg">PRTG</a> monitors data traffic, availability and performance of devices and applications in IT infrastructures. This includes monitoring for classic network devices such as servers, routers, switches and firewalls, as well as virtual environments and also — as in this example — you can use the right scripts to monitor cloud components such as Microsoft Endpoint Manager.</p><p>In this example, we would like to measure the following Microsoft Endpoint Manager indicators with PRTG:</p><ul><li>Number of managed devices (Windows, MacOS, iOS, Android)</li><li>Number of devices by operating system</li><li>Number of devices that are not compliant</li><li>Number of devices that are not encrypted</li></ul><p><a href="https://opensight.ch/produkt/prtg-sensor-monitoring-microsoft-endpoint-manager/">Powershell Script Download</a></p><h4>Prerequisites</h4><p>A Service Principal (app registration) is required in Azure AD in order to be able to read out the desired indicators. This must have the appropriate read permissions in the Microsoft Graph API (DeviceManagementManagedDevices.Read.All).<br><a href="https://docs.microsoft.com/de-de/azure/role-based-access-control/built-in-roles#reader">https://learn.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals</a></p><p>The Powershell module «MSAL.PS» is installed on the PRTG server or the PRTG probe. It is the Microsoft Authentication Library module, which is required so that the script can retrieve an access token.</p><pre>Install-Module MSAL.PS -Scope AllUsers -Force</pre><p>The script uses this library at one point to get an access token:</p><pre># acquire azure authentication token<br>$MsalToken = Get-MsalToken -TenantId $tenant_id -ClientId $app_id -ClientSecret ($client_secret | ConvertTo-SecureString -AsPlainText -Force)<br> <br>#Connect to Graph using access token<br>Connect-Graph -AccessToken $MsalToken.AccessToken</pre><figure><img alt="Unable to find package provider &#39;NuGet&#39;" src="https://cdn-images-1.medium.com/max/835/0*bsCJB-RXw6vCm883.png" /></figure><p>If the above error message appears, NuGet cannot be installed, TLS 1.2 must first be enforced.</p><pre>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12<br>Install-PackageProvider NuGet</pre><h4>Service principal (app registration)</h4><p>Now a “Service Principal” (app registration) including Secret must be created in Azure Active Directory.<br>During this process you will receive various information, which you then need to run the monitoring script so that it can access the information in Azure:</p><ul><li>application id (app_id)</li><li>azure tenant id (tenant_id)</li><li>application client secret (client_secret)</li></ul><p>The creation of the Service Principal is described in detail in the download (readme).</p><h4>Powershell Graph API</h4><p>The desired Endpoint Manager indicators are provided by Microsoft via the Graph API. In the past, each product had its own API or even multiple APIs. Exchange knows EWS, REST, ActiveSync and MAPI/HTTP, Skype for Business has a UCWA and a UCMA and so the story can be told endlessly. Each API has its own URL, methods and format, and authentication mechanisms.</p><p>With Microsoft Graph, Microsoft wants to provide uniform access to all data via a REST interface. Our script will use the following endpoint:</p><pre>https://graph.microsoft.com/V1.0/deviceManagement/managedDevices</pre><p>This is documented in more detail <a href="https://learn.microsoft.com/en-us/graph/api/intune-devices-manageddevice-list?view=graph-rest-1.0">here</a> at Microsoft.</p><h4>Script</h4><p><a href="https://opensight.ch/produkt/prtg-sensor-monitoring-microsoft-endpoint-manager/">Powershell Script Download</a></p><p>Download the PowerShell script or the ZIP and unpack it in the PRTG Probe path C:/Program Files (x86)/PRTG Network Monitor/Custom Sensors/EXEXML.</p><p>Powershell scripts downloaded from the internet still need to be unblocked.</p><pre>Unblock-File v2_prtg_intune_device_monitor.ps1</pre><h4>PRTG Configuration</h4><h4>Create Device</h4><ul><li>Create a device in PRTG, e.g. Microsoft 365 (IP address irrelevant, e.g. 127.0.0.1).</li><li>Enter the Azure user name and password created above in the properties of the device under Credentials for Windows Systems for Username and Password. Username must be the user’s email address.</li></ul><h4>Create Sensor</h4><ul><li>Create a new <a href="https://www.paessler.com/manuals/prtg/exe_script_advanced_sensor">EXE/Script Advanced</a> sensor for the device.</li><li>Select “Powershell Script — Endpoint Manager Overview.ps1” for the script selection.</li><li><strong>V1</strong> (didn’t use a service principal — just a normal user without MFA)<br>In the parameter field, enter -username “%windowsuser” -password “%windowspassword”.</li><li><strong>v2</strong><br>Enter in parameter field:<br>-app_id “&lt;%azure_application_id&gt;”<br>-tenant_id “&lt;%azure_tenant_id&gt;”<br>-client_secret “&lt;%azure_application_client_secret&gt;”</li><li>Increase timeout from 60s to 120s.</li><li>Configure the interval to suit your needs, e.g. once every hour.</li></ul><figure><img alt="PRTG Intune Endpoint Manager Sensor Settings" src="https://cdn-images-1.medium.com/max/1024/0*Rj184f9-IhAk54hY.png" /></figure><p>The alerts are individual, so the desired thresholds should be defined in the channel settings under Value Lookups and Limits. <a href="https://www.paessler.com/manuals/prtg/sensor_channels_settings">https://www.paessler.com/manuals/prtg/sensor_channels_settings</a></p><p>If everything went well, the desired indicators can be seen in the monitoring:</p><figure><img alt="PRTG Intune Endpoint Manager Sensor" src="https://cdn-images-1.medium.com/max/1024/0*MnF3URSWudhbSi3d.png" /></figure><ul><li>Number of managed devices (Windows, MacOS, iOS, Android)</li><li>Number of devices by operating system</li><li>Number of devices that are not compliant</li><li>Number of devices that are not encrypted</li></ul><p>Important Microsoft Endpoint Manager information is displayed in the monitoring with little effort and an alarm is triggered by email, ticket, Microsoft Teams, etc. when a defined threshold value is exceeded.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5b118e61106" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/prtg-monitoring-intune-graph-api-microsoft-endpoint-manager-d5b118e61106">PRTG — Monitoring Intune (Graph API, Microsoft Endpoint Manager)</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One problem less — Fully Automatic Windows Server Patching with Ansible]]></title>
            <link>https://medium.com/opensight-ch/one-problem-less-fully-automatic-windows-server-patching-with-ansible-2e857d11737f?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/2e857d11737f</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[awx]]></category>
            <category><![CDATA[updates]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Sun, 31 Jul 2022 16:03:56 GMT</pubDate>
            <atom:updated>2023-03-18T08:12:06.844Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AXN5QLspVXsimizz.jpg" /></figure><blockquote><strong>Are you still patching manually?</strong><br>Do you still manually patch your virtual Windows servers? With complete automation, you save time and effort here and also increase security. Fully automated server patching with ansible…</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><p><a href="https://github.com/butschi84/ansible-server-patching/tree/awx">Ansible Patching Github</a></p><p><strong>Fully automated server patching with ansible</strong></p><ul><li>“Are there new security updates for my server VM’s?”</li><li>“Did the backup run successfully last night?”</li><li>“Does the VM have existing snapshots?”</li><li>“Does the VM have enough free disk space?”</li><li>“Can I start patching the VMs at 21:00 in the evening?”</li></ul><p>You can either find out the answers to these questions manually on your infrastructure or automate this process from A-Z using Ansible. The patching process often involves necessary checks and precautions on all peripheral systems (backup, hypervisor snapshots, monitoring). In this blog post we would like to show how the open source tool “Ansible” can help with automation.</p><blockquote>Before we get started — you can also take a look at all the playbooks and modules mentioned in our corresponding <a href="https://github.com/butschi84/ansible-server-patching">open source repository on Github</a>.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><h4>About Ansible</h4><p>Ansible is an automation tool (open source) that combines functions such as software distribution, ad hoc command execution and configuration management.</p><p>The Ansible system uses files in YAML format (playbooks) to describe the desired status of systems. The Ansible “master server” then connects to the “slave servers” (or WinRM in the case of Windows) via SSH in order to carry out the necessary configurations. There are numerous out-of-the-box “Ansible modules” with which you can carry out all sorts of system configurations. Of course, you can also develop your own modules — we use exactly those for checks on peripheral systems such as Hyper-V hosts.</p><blockquote><strong>Gitops / Infrastructure as Code</strong><br>If you combine Ansible (or its YAML files) with the functionalities of GIT, you have the option of versioning the configuration of your infrastructure. Keyword “Infrastructure as Code (IaC)”, “Gitops”</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><h4>Web GUI — AWX Installation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W31JtHxEwGA7iBsU.png" /><figcaption><em>Image — AWX Login Screen</em></figcaption></figure><p>Today, Ansible is one of the most established open source orchestration tools. It is based on the Python programming language and is operated via the command line. However, there are also graphic interfaces that make operation easier, offer a better overview and also provide scheduling functions. Red Hat’s “Ansible Tower” is the most well-known graphical user interface — however, we’re using the <a href="https://github.com/ansible/awx">open source version</a> of it here: “Ansible AWX”.</p><p>In our case, we used an existing Kubernetes cluster to set up AWX — but of course there are other options. The “AWX Operator” is recommended for deploying AWX version 20 on Kubernetes. This creates a Custom Resource Definition (CRD) “AWX” on your Kubernetes cluster, which manages the AWX deployment. The database runs on PostgreSQL. We cannot go into detail about the installation at this point, but the documentation can be found <a href="http://github.com/ansible/awx-operator(opens%20in%20a%20new%20tab)">here</a>.</p><h4>Configuration of Windows Slaves</h4><blockquote>This blog post focuses in particular on patching Windows server systems with Ansible. However, you can also patch Linux systems in the same way (in a slightly different way).</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><p>For Ansible to access a Windows Slave Server VM to be patched, the Windows Server must have at least PowerShell version 3.0 and .NET Framework 4.0 installed. After that, the WinRM service needs to be configured for Ansible. The WinRM service on the target systems should be configured correctly so that communication can take place securely and encrypted. We recommend our blog post “<a href="https://en.opensight.ch/blog/2021/12/28/winrm-remoteverwaltung-von-windows-servern">WinRM — Remote administration of Windows servers</a>”.</p><h4>Creating Ansible Playbooks</h4><p>Now let’s prepare some playbooks that help us achieving our goal “Fully automated server patching with ansible”. There are some playbooks in the <a href="https://github.com/butschi84/ansible-server-patching/tree/main/playbooks/patch-windows">GIT repository</a> that will be useful when patching Windows servers:</p><ul><li><strong>Playbook — Check Windows Updates</strong><br>Performs a search for available Windows updates on the clients</li><li><strong>Playbook — Check Disk Space</strong><br>Checks whether the c: drive has at least 20GB of free space</li><li><strong>Playbook — Check VM Snapshots</strong><br>Checks if the VM has active snapshots on the virtualization server</li></ul><p>A sequence of “tasks” is defined in each playbook, which are to be carried out on the defined systems in sequence. If one of these tasks fails, execution is aborted.</p><h4>Playbook — Check Windows Updates</h4><p>Now it’s time to test the system. We use a playbook (<a href="https://github.com/butschi84/ansible-server-patching/blob/main/playbooks/patch-windows/check-updates.yml">check-updates.yml</a>) for this, which lists the available updates on all Windows servers.</p><pre>---<br><br>- name: windows server patching<br>  hosts: all<br>  tasks:<br><br>    - name: Check for missing updates<br>      win_updates:<br>        state: searched<br>      register: update_results<br><br>    - name: report update results<br>      debug:<br>        msg: |<br>          {% for k in update_results.updates %}<br>          {{ k.title }}<br>          {% endfor %}</pre><blockquote>playbook — check-updates.yml</blockquote><p>We integrate the playbook into Ansible AWX as a “Job Template”. After its execution we see (image — lines in green) that a Windows system has pending updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o9YmNX8G30prPe9F.png" /><figcaption><em>Image — Ansible Job / Playbook check-updates.yml Result</em>s</figcaption></figure><h4>Playbook — Check Disk Space</h4><p>Similarly, we define another job template that checks the available storage space on the c: drive. If less than 20GB is available, this test is said to fail.</p><pre>---<br><br>- name: check free disk space<br>  hosts: all<br>  tasks:<br>    - name: &#39;Check free space in C:&#39;<br>      win_shell: &#39;write-host ([math]::Round((Get-PSDrive C | Select-Object Free).free / 1024 / 1024 / 1024,2))&#39;<br>      register: freespace<br><br>    - name: report free disk space<br>      debug:<br>        msg: |<br>          &quot;{{ freespace.stdout }} GB&quot;<br><br>    - name: fail if there is not enough space<br>      fail:<br>        msg: &quot;VM {{inventory_hostname}} has not enough space&quot;<br>      when: &quot;{{freespace.stdout | int &lt; 20}}&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DTYISxX4oxOz2frs.png" /><figcaption><em>Image — Ansible Job / Playbook check-diskspace.yml Result</em></figcaption></figure><h4>Playbook — Check VM Snapshots</h4><p>In our case we want the patching to start only when there are no active snapshots on the virtual machines (just as an example to see what’s possible).</p><p>In the GIT repository we have a <a href="https://github.com/butschi84/ansible-server-patching/blob/awx/library/action_plugins/hyperv_check_snapshots/hyperv_check_snapshots.ps1">custom module</a> for Ansible, which can check whether a Hyper-V VM currently has a snapshot. So let’s test:</p><ul><li>We create a snapshot of the VM bnetprtg01</li><li>In the Ansible Inventory, we add the variable “hyperv_vmname=bnetprtg01” to the host bnetprtg01, which is necessary for the module / playbook. (see <a href="https://github.com/butschi84/ansible-server-patching/blob/awx/README.md">documentation</a>)</li><li>We add the necessary variable “module_hyperv_host: 192.168.1.2” to the Ansible inventory, which points to the Hyper-V host. (see <a href="https://github.com/butschi84/ansible-server-patching/blob/awx/README.md">documentation</a>)</li><li>Then we run the playbook from the git repository (<a href="https://github.com/butschi84/ansible-server-patching/blob/awx/playbooks/hyperv/hyperv-check-nosnapshots.yml">hyperv-check-nospanshot.yml</a>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CED3Q57DYPbIV4LA.png" /><figcaption><em>Image — Ansible playbook failed for VM bnetprtg01, because it has active snapshots</em></figcaption></figure><p>As hoped, the playbook for the VM bnetprtg01 fails because it has an active snapshot. Of course, the same playbook could be modified slightly to create a snapshot before patching and delete it after patching.</p><blockquote>Take a look at the GIT repository, it also contains playbooks for checking the monitoring status of a system in PRTG, pausing or resuming the monitoring.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><p>We will not describe other playbooks at this point. But of course it is also possible to check or change the snapshots analogously to a VMware-based infrastructure. Or to check the backup on a Veeam server, etc.</p><h4>Grande Finale — Fully Automated Patching Process</h4><p>With a “workflow job template” we now link all previously defined playbooks (“job templates”) in Ansible AWX to a complete automated process.</p><ul><li>Check disk space</li><li>Check snapshots</li><li>Looking for updates</li><li>Install updates and restart</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jj9Q_IuGDdbUPeLV.png" /><figcaption><em>Image — AWX fully automatic patching workflow</em></figcaption></figure><p>We define a job schedule so that a fully automatic Windows Server patching is carried out once a month, at 02:00 in the morning. In a real patching scenario, it would be best to synchronize the patching time with “Microsoft Patch Tuesday”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ur34vL4kwI9JKZmU.png" /><figcaption><em>Image — Windows Patching Schedule</em></figcaption></figure><h4>Reporting and Notifications</h4><p>With regard to reporting, for example, you have the option of setting up an e-mail notification.<br>The formatting of the e-mail can be adjusted slightly. However, there are of course other and more advanced options. As an example, you could stream all the logs into an Elasticsearch cluster using Logstash, which we may look at in a future blog post.</p><h4>Wrapping up</h4><p>Ansible has rightly risen to the premier league of the most popular orchestration and automation tools. Operation is intuitive and of course you can also use it to automate processes other than “Fully automated server patching with ansible”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e857d11737f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/one-problem-less-fully-automatic-windows-server-patching-with-ansible-2e857d11737f">One problem less — Fully Automatic Windows Server Patching with Ansible</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform — Deploy GKE Kubernetes Cluster incl. Workloads (Certmanager, Nginx Ingress, Testapp)]]></title>
            <link>https://medium.com/opensight-ch/terraform-deploy-gke-kubernetes-cluster-incl-workloads-certmanager-nginx-ingress-testapp-81bc6305136e?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/81bc6305136e</guid>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Wed, 27 Jul 2022 20:50:02 GMT</pubDate>
            <atom:updated>2022-07-27T20:50:02.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2P0kEhG-j17IG_jT.jpg" /></figure><blockquote>Today we deploy a complex Kubernetes cluster on the Google Cloud Platform including workloads (NGINX Ingress, Cert Manager, Testapp) in about 10 minutes.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><p>We use the Terraform tool for this. Manually you need at least several hours to configure all services. The “Infrastructure as Code” approach with Terraform requires an initial effort. You can then create such complex clusters with just a few clicks.</p><p><a href="https://github.com/butschi84/terraform-gke">GIT Repository</a></p><h4>Inhalt</h4><ul><li><a href="#design">Cluster Design</a></li><li><a href="#prerequisites">Prerequisites</a></li><li><a href="#terraform">What is Terraform</a></li><li><a href="#deployment">Deployment of a GKE Cluster</a></li></ul><h4>Cluster Design</h4><p>Specifically, it is about a GKE deployment for a cluster with 1 node and workloads:</p><ul><li><strong>GKE Cluster</strong></li><li><strong>Nodepool</strong><br>1 Node (n1-standard-1)</li><li><strong>Network</strong><br>VPC (10.0.0.0/18)<br>Subnet k8s-pod-range (10.48.0.0/16)<br>Subnet k8s-service-range (10.52.0.0/16)<br>NAT Gateway (outbound traffic)</li><li><strong>Workloads</strong></li><li><strong>NGINX Ingress Controller (HELM Chart)</strong><br>Creates corresponding load balancer with public IP in GCP</li><li><strong>Cert Manager (HELM Chart)</strong><br>Automatically issues SSL certificates for Nginx Ingress resources<br>e.g. for the web service in the “testapp” module</li><li><strong>Test-App (nginx webserver)</strong><br>Simple example web service for testing</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jgYgacCbM0hDHboZ.png" /><figcaption><em>Image — GKE Deployment according to the Terraform Charts in GIT Repo</em></figcaption></figure><p>All source code files described can be found in the public GIT repository (link on top).</p><p>The GKE cluster that we are installing is a private cluster — the clsuter nodes do not have a public IP address and are therefore not directly accessible via the Internet. Outbound traffic is routed through the NAT gateway. Incoming traffic (HTTP, HTTPS) is routed through a Google Load Balancer to an NGINX Ingress Controller on Kubernetes. We define a VPC and some subnets for address assignment. This is a test cluster — to save costs we only create one node, but make provisions in the code to also have a zonal cluster with redundant nodes spread over several zones if required.</p><p>All right — on to implementation.</p><h4>Prerequisites</h4><p>Today’s blog post deals with the topic “Infrastructure as Code” — in order to follow the steps described, you should already be familiar with GIT and GIT repositories and the Terraform Basics.</p><h4>What is Terraform</h4><p>Terraform is an “Infrastructure as Code” tool from Hashicorp. It makes it possible to define entire infrastructures as code (declarative) to describe the desired end state of the infrastructure and then deploy the whole thing in the cloud.</p><p>After the infrastructure has been deployed, Terraform saves the “state” of the infrastructure. The state contains all information about the infrastructure that you have deployed in the cloud. For example, it is possible to shut down the infrastructure completely or to detect manual changes to the infrastructure. If you don’t define anything else, Terraform will store its state in a local file (terraform.tfstate). In enterprise environments, however, the state is usually stored in the cloud (e.g. Terraform Cloud, Amazon S3 Bucket, etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QaaDf36UJviTcAj9.png" /><figcaption><em>Image — Sample Terraform Statefile of a Google Kubernetes Ressource (google_container_cluster)</em></figcaption></figure><p>Installing Terraform is quick and a manual can be found <a href="https://learn.hashicorp.com/tutorials/terraform/install-cli">here</a>.</p><p><strong>Most important commands</strong></p><pre># Initialisation of all terraform modules for the project<br>terraform init<br><br># compare the state of the infrastructure with the declaration (tf files)<br># plan changes to the infrastructure<br>terraform plan<br><br># make the necessary changes in the infrastructure to match the declaration<br>terraform apply<br><br># make the necessary changes in the infrastructure to match the declaration<br># but just for module test_app<br>terraform apply -target module.test_app<br><br># roll back the infrastructure<br>terraform destroy<br><br># roll back the infrastructure<br># but just the module test_app<br>terraform destroy -target module.test_app</pre><h4>Deployment of a GKE Cluster</h4><p>Here we go. First, let’s clone the GIT repository and login to Google Cloud. For this you need the “gcloud” command / the Google Cloud CLI (<a href="https://cloud.google.com/sdk/docs/install-sdk">instructions</a>) on your computer.</p><pre># clone git repo<br>git clone https://github.com/butschi84/terraform-gke.git<br>cd terraform-gke<br><br># initialize terraform module<br>terraform init<br><br># login on google cloud<br>gcloud auth login<br><br># edit variables.tf<br>- in variables.tf you can add your private IP address (whitelist-ips), so that you can access the control plane / kubernetes api server of the cluster after creation<br>- also you should specify the name of your gcp project<br>- in the file clusterissuer.yaml you can set your e-mail adress in order to receive notifications about expiring certs. cert manager will take care of cert renewal automatically though<br><br># create infrastructure (gke cluster and workloads)<br>terraform apply<br><br># info - reapply just a module<br>terraform apply -target module.</pre><p>A video of the deployment process with terraform can be found on youtube.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FRvjRI7K98Us%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DRvjRI7K98Us&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FRvjRI7K98Us%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d2011b52374e0beb4b9061737c2bac8/href">https://medium.com/media/3d2011b52374e0beb4b9061737c2bac8/href</a></iframe><p><em>Video — Terraform GKE Deployment</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81bc6305136e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/terraform-deploy-gke-kubernetes-cluster-incl-workloads-certmanager-nginx-ingress-testapp-81bc6305136e">Terraform — Deploy GKE Kubernetes Cluster incl. Workloads (Certmanager, Nginx Ingress, Testapp)</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CICD, K8S, Gitlab, Kaniko — Container Builds on a private Kubernetes Cluster]]></title>
            <link>https://medium.com/opensight-ch/cicd-k8s-gitlab-kaniko-container-builds-on-a-private-kubernetes-cluster-a9835aba7d7a?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/a9835aba7d7a</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Sat, 23 Jul 2022 11:26:04 GMT</pubDate>
            <atom:updated>2023-03-18T08:16:04.324Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TDP4NDtO4rSHV2W9.jpg" /></figure><blockquote>Usually CI/CD jobs in Gitlab are executed on the shared runners. If you would like to run builds and CI/CD jobs on your own Kubernetes infrastructure, then today’s blog post is for you. We show how you can run container builds on the private Kubernetes cluster.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><p>You can build Docker container images with the already very familiar “docker build” command. So you need an appropriate host where the Docker Engine and Command Line Tools are installed. However, what if you would like to run the builds on your existing Kubernetes cluster in a pod? This is what <a href="https://github.com/GoogleContainerTools/kaniko/blob/main/README.md">Kaniko</a> is for and that’s what today’s blog post is about.</p><p>In a few steps we create a CI/CD pipeline on Gitlab, which should meet the following requirements or the project has the following properties:</p><ul><li>NodeJS project</li><li>Google Container Registry</li><li>Gitlab CI/CD Pipeline</li><li>Gitlab Runner on our local Kubernetes cluster</li><li>Docker builds are run on Kaniko’s own Kubernetes cluster</li></ul><p>Of course, we hope that some of the processes described will also help you with your individual setup.</p><p><strong>Prerequisites</strong></p><ul><li>We assume that you already have a NodeJS project (or similar) on Gitlab with which to do this setup.</li><li>We assume that you already have a Kubernetes cluster and have configured the HELM CLI tool.</li><li>We assume you already have a container registry, for example on Google Cloud</li></ul><p><strong>Contents</strong></p><ul><li><a href="#runner">Setup Gitlab Runner</a></li><li><a href="#pipeline">CICD Pipeline</a></li><li><a href="#vars">Pipeline Variables, Authentication Container Registry</a></li><li><a href="#pip">CICD Pipeline</a></li></ul><h4>Setup Gitlab Runner</h4><p>We don’t want our Gitlab CI/CD pipeline to run on a public node, but locally on our own Kubernetes cluster. Therefore we install a Gitlab Runner on the cluster.</p><p>The Gitlab runners are displayed in the Gitlab project under “Settings / CICD”. Also a registration token to register our local runner (oranged out), as well as instructions to install the runner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h59MoFBY2aH7JghD.png" /><figcaption><em>Image — Gitlab CICD Runner Configuration</em></figcaption></figure><p>According to the instructions, we connect to the Kubernetes cluster (SSH) and add the HELM repository. After that we create a values.yaml with installation parameters and then install the gitlab runner.</p><pre># add helm repository<br>helm repo add gitlab https://charts.gitlab.io<br><br># configure installation parameters<br>cat &lt;&lt; EOF &gt; values.yaml<br>gitlabUrl: https://gitlab.com<br>runnerRegistrationToken: xxxxxxxxx<br>rbac:<br>  create: true<br>EOF<br><br># gitlab runner installation on k8s<br>helm install gitlab-runner -f values.yaml gitlab/gitlab-runner</pre><p>After a short wait, the K8S Pod is started and the runner is displayed in the Gitlab. The “Shared Runner” can now be deactivated in Gitlab under “Settings / CICD / Runner”.</p><p>If a CI/CD job is now executed, the Gitlab Runner will automatically start a pod on our Kubernetes cluster, which houses the CI/CD job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1fJsKq-TZRVYXfyg.png" /><figcaption><em>Image — Pod in Kubernetes Cluster for Gitlab Runner CI/CD Job</em></figcaption></figure><h4>CICD Pipeline</h4><p>Our NodeJS project already contains a simple Dockerfile.</p><pre>FROM node:latest<br># Create app directory<br>WORKDIR /usr/src/app<br><br># Install dependencies (npm is already installed)<br>COPY package*.json ./<br>RUN npm install<br><br># Bundle app source<br>COPY . .<br><br>EXPOSE 3000<br>CMD [ &quot;npm&quot;, &quot;start&quot; ]</pre><p>Now we want to configure the Gitlab CI/CD pipeline in such a way that CI/CD jobs are executed on our Gitlab Runner (i.e. on our own Kubernetes cluster) and Docker container images / builds are made using Kaniko.</p><h4>Pipeline Variables, Authentication Container Registry</h4><p>So that the pipeline can access the container registry and upload the generated container image, we should first define some variables in the Gitlab project.</p><pre>=&gt; <strong>CI_Registry<br></strong>Path to container registry i.e. on google cloud<br>z.B. &quot;eu.gcr.io&quot;<br><br>=&gt; (<strong>CI_REGISTRY_USER</strong>)<br>username for container registry access<br><br>=&gt; (<strong>CI_REGISTRY_PASSWORD</strong>)<br>password for container registry access<br><br>=&gt; <strong>CI_REGISTRY_KEYFILE</strong><br>Instead of username / password, we use a json keyfile for the google container registry</pre><p>From the variables CI_REGISTRY_USER and CI_REGISTRY_PASSWORD we can create a Docker config.json in the CI/CD pipeline for Kaniko, which contains the credentials for connecting to the container registry.</p><pre>mkdir -p /kaniko/.docker<br>echo &quot;{\&quot;auths\&quot;:{\&quot;${CI_REGISTRY}\&quot;:{\&quot;auth\&quot;:\&quot;$(printf &quot;%s:%s&quot; &quot;${CI_REGISTRY_USER}&quot; &quot;${CI_REGISTRY_PASSWORD}&quot; | base64 | tr -d &#39;\n&#39;)\&quot;}}}&quot; &gt; /kaniko/.docker/config.json</pre><p>However, in this case today, we are using the Google Container Registry and using a <a href="https://cloud.google.com/container-registry/docs/advanced-authentication?hl=de#json-key">JSON key file</a> to authenticate with the Container Registry. A slightly different approach is therefore necessary.<br>We create a service account (“gitlab-service-account”) with “Storage Administrator” role in the Google Cloud (IAM &amp; Admin). Then we export the keyfile.json of the account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XVXQALl0EzqyVT7l.png" /><figcaption><em>Image — Google Container Registry. IAM Service User Keyfile export</em></figcaption></figure><p>We store the file in the Gitlab project as a “File” variable “CI_REGISTRY_KEYFILE”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oahTK4_aS80qCfoS.png" /><figcaption><em>Image — Gitlab CICD Variable CI_REGISTRY_KEYFILE</em></figcaption></figure><p>From the key file we later configure the authentication file for Kaniko in the CI/CD pipeline:</p><pre>echo &quot;{\&quot;auths\&quot;:{\&quot;${CI_REGISTRY}\&quot;:{\&quot;auth\&quot;: \&quot;$(echo _json_key: $(cat $CI_REGISTRY_KEYFILE) | base64 | tr -d &#39;\n&#39;)\&quot;}}}&quot; &gt; /kaniko/.docker/config.json</pre><p>The Gitlab project should now look like this, so that an active runner is visible under “Settings / CICD”. The “Shared Runner” can be deactivated at the same place. In addition, the variables CI_REGISTRY and CI_REGISTRY_KEYFILE are defined, where CI_REGISTRY_KEYFILE is a variable of the “File” type.</p><h4>CI / CD Pipeline</h4><p>Add a “.gitlab-ci.yml” file to the project, in which the CI/CD pipeline is defined.<br>In the file we define in the “Build Stage” that container images should be created according to the Dockerfile (by Kaniko) and then uploaded to the Google Container Registry.</p><pre># build will run on this image on gitlab<br>image: docker:latest<br><br>services:<br>  - docker:dind<br><br>variables:<br>  GKE_PROJECT: quickstart-12345678<br>  IMAGE_NAME: my-container-image-name<br>  APP_VERSION: 1.0<br><br>stages:<br>  - build<br><br># use &quot;docker in docker&quot; for image build<br>build:<br>  stage: build<br>  image:<br>    name: gcr.io/kaniko-project/executor:debug<br>    entrypoint: [&quot;&quot;]<br>  script:<br>    # hide the kaniko aws error<br>    - |<br>      export AWS_ACCESS_KEY_ID=&quot;none&quot;<br>      export AWS_SECRET_ACCESS_KEY=&quot;none&quot; <br>      export AWS_ACCAWS_SESSION_TOKENESS_KEY_ID=&quot;none&quot;<br><br>    # container registry credentials<br>    - mkdir -p /kaniko/.docker<br>    - echo &quot;{\&quot;auths\&quot;:{\&quot;${CI_REGISTRY}\&quot;:{\&quot;auth\&quot;: \&quot;$(echo _json_key: $(cat $CI_REGISTRY_KEYFILE) | base64 | tr -d &#39;\n&#39;)\&quot;}}}&quot; &gt; /kaniko/.docker/config.json<br>    - cat /kaniko/.docker/config.json<br><br>    # build and push container image using kaniko<br>    - &gt;-<br>      /kaniko/executor<br>      --context &quot;.&quot;<br>      --dockerfile &quot;./Dockerfile&quot;<br>      --destination &quot;${CI_REGISTRY}/${GKE_PROJECT}/${IMAGE_NAME}:${APP_VERSION}&quot;<br>      --destination &quot;${CI_REGISTRY}/${GKE_PROJECT}/${IMAGE_NAME}:latest&quot;</pre><h4>Container Builds on a private Kubernetes Cluster</h4><p>Now you can run container builds on the private Kubernetes cluster and run Docker builds using Kaniko.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9835aba7d7a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/cicd-k8s-gitlab-kaniko-container-builds-on-a-private-kubernetes-cluster-a9835aba7d7a">CICD, K8S, Gitlab, Kaniko — Container Builds on a private Kubernetes Cluster</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NGINX Ingress WAF (Part 2) — mod_security Kibana Dashboard]]></title>
            <link>https://medium.com/opensight-ch/nginx-ingress-waf-part-2-mod-security-kibana-dashboard-2fd863180d47?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/2fd863180d47</guid>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[geoip]]></category>
            <category><![CDATA[fluentd]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[kibana]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Mon, 16 May 2022 18:26:34 GMT</pubDate>
            <atom:updated>2022-05-16T18:26:34.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SMTSglmmuahJ7Ty4.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XXu87gHJG09Ijlye.jpg" /><figcaption><em>Image — Kibana Dashboard for ModSecurity WAF of NGINX Ingress Controller</em></figcaption></figure><p>In the first part of the blog (<a href="https://en.opensight.ch/blog/2021/12/02/zerotrust-kubernetes-nginx-ingress-hardening-mit-mod_security-waf-und-owasp-crs/">Kubernetes NGINX Ingress Hardening with Mod_Security WAF and OWASP CRS</a>), we configured our NGINX Ingress Controller on Kubernetes so that the WAF (Web Application Firewall) is activated and our webapps are protected from attacks. Now let’s build a Kubernetes NGINX Ingress WAF Dashboard.</p><p>Today in the second part it is about getting a better overview of current attacks and the activity of our WAF. To do this, we attach a Fluentd sidecar container to the NGINX ingress controller, which monitors the ModSecurity WAF log and sends new events to the Elasticsearch cluster. We also add the fluentd geoip plugin so that attackers’ IP address is resolved to a location so that we can later display a world map in Kibana with the Attack Origins. The result is a Kibana dashboard that provides a good overview of Web Application Firewall (WAF) activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B459pXtmjbxj2TuX.jpg" /><figcaption><em>Image — Dashboard activities of the WAF</em></figcaption></figure><h4>Custom Build — Fluentd</h4><p>We add our own Fluentd sidecar container to the NGINX ingress controller in Kubernetes, which monitors the ModSecurity log and sends all events to the Elasticsearch cluster. To do this, we create a Fluentd Custom Build Container, which has a plugin installed to interpret the ModSecurity logs, as well as a GeoIP plugin to resolve the geo-location using the IP addresses of the attackers.</p><p>We have an <a href="http://github.com/butschi84/fluentd-modsec">example repository</a> here that you can use to build the FluentD container with the necessary dependencies. Then we upload the container image to our Google Container Repository:</p><pre>docker build -t gcr.eu.io/meinprojekt/docker-modsec-fluentd:1.4 .<br>docker push gcr.eu.io/meinprojekt/docker-modsec-fluentd:1.4</pre><h4>Configmap for FluentD</h4><p>First we create the fluent.conf and make it available in Kubernetes using a configmap. The config ensures that all entries from /var/log/modsecurity_audit.log are read out, formatted, a GEO IP is resolved and the result is saved in Elasticsearch.</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: nginx-log-fluentd-config<br>  namespace: ingress-nginx<br>data:<br>  fluent.conf: |<br>    # (1) Consume the input<br>    &lt;source&gt;<br>      @type tail<br>      tag raw-modsec<br>      path /var/log/modsecurity_audit.log<br>      &lt;parse&gt;<br>        @type multiline<br>        format_firstline /^-{2,3}[a-zA-Z0-9]{8}-{2,3}A--$/<br>        format1 /(?&lt;message&gt;.*)/<br>      &lt;/parse&gt;<br>    &lt;/source&gt;<br><br>    # (2) Massage it via this plugin to a more structured object<br>    &lt;match raw-modsec&gt;<br>      @type modsecurity-audit-format<br>      tag modsec-formatted<br>    &lt;/match&gt;<br><br>    &lt;filter modsec-formatted&gt;<br>      @type grep<br><br>      &lt;exclude&gt;<br>        key sourceIp<br>        pattern /127.0.0.1/<br>      &lt;/exclude&gt;<br>    &lt;/filter&gt;<br><br>    &lt;filter modsec-formatted&gt;<br>      @type geoip<br>      geoip_lookup_keys  sourceIp<br>      backend_library geoip2_c<br>      log_level         info<br><br>      &lt;record&gt;<br>        city            ${city.names.en[&quot;sourceIp&quot;]}<br>        latitude        ${location.latitude[&quot;sourceIp&quot;]}<br>        longitude       ${location.longitude[&quot;sourceIp&quot;]}<br>        location_properties  &#39;{ &quot;lat&quot; : ${location.latitude[&quot;sourceIp&quot;]}, &quot;lon&quot; : ${location.longitude[&quot;sourceIp&quot;]} }&#39;<br>        country         ${country.iso_code[&quot;sourceIp&quot;]}<br>        country_name    ${country.names.en[&quot;sourceIp&quot;]}<br>        postal_code     ${postal.code[&quot;sourceIp&quot;]}<br>        region_code     ${subdivisions.0.iso_code[&quot;sourceIp&quot;]}<br>        region_name     ${subdivisions.0.names.en[&quot;sourceIp&quot;]}<br>      &lt;/record&gt;<br>      #skip_adding_null_record true<br>      add_tag_prefix          geoip.<br>      flush_interval          5s<br>    &lt;/filter&gt;<br><br>    # (3) Output to stdout<br>    &lt;match modsec-formatted&gt;<br>      @type elasticsearch<br>      hosts &quot;#{ENV[&#39;ES_HOSTS&#39;]}&quot;<br>      user &quot;#{ENV[&#39;ES_USERNAME&#39;]}&quot;<br>      password &quot;#{ENV[&#39;ES_PASSWORD&#39;]}&quot;<br>      port &quot;443&quot;<br>      ssl_verify false<br>      scheme https<br>      ssl_version TLSv1_2<br>      protocol https<br><br>      flush_interval 5s<br>      with_transporter_log true<br>      type_name doc<br>      logstash_prefix modsecurity<br>      logstash_dateformat %Y.%m<br>      logstash_format true<br>      include_timestamp true<br><br>      reconnect_on_error true<br>      reload_on_failure true<br>      reload_connections false<br>    &lt;/match&gt;<br><br>    &lt;match modsec-formatted&gt;<br>      @type stdout<br>    &lt;/match&gt;</pre><h4>FluentD Sidecar Container</h4><p>Now the NGINX Ingress Controller Deployment on Kubernetes is configured so that all containers can access the Modsecurity Log. We also attach the previously created FluentD container as a sidecar container:</p><pre>- name: fluentd-modsec<br>  image: my-container-registry.com/docker-modsec-fluentd:1.4<br>  command:<br>  - fluentd<br>  - &#39;-c&#39;<br>  - /etc/fluentd/fluent.conf<br>  env:<br>  - name: ES_HOSTS<br>    value: https://elastic.*****.com:443<br>  - name: ES_USERNAME<br>    value: elastic_user<br>  - name: ES_PASSWORD<br>    value: ********<br>  volumeMounts:<br>  - name: nginx-logdir<br>    mountPath: /var/log<br>  - name: nginx-log-fluentd-config<br>    mountPath: /etc/fluentd/fluent.conf<br>    subPath: fluent.conf</pre><h4>Elasticsearch Configuration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zno1lc5DtRTMTprJ.png" /></figure><p>In Elasticsearch, we use an index template to ensure that the mapping of the “location_properties” field is later defined as “geo_point” in the index.</p><h4>Kubernetes NGINX Ingress WAF Dashboard</h4><p>If everything is now configured correctly, the NGINX Ingress Controller (or the FluentD Sidecar Container) will now send all logs to the Elasticsearch Cluster. In Kibana, you can now use the data to configure a Kubernetes NGINX Ingress WAF dashboard that displays the data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd863180d47" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/nginx-ingress-waf-part-2-mod-security-kibana-dashboard-2fd863180d47">NGINX Ingress WAF (Part 2) — mod_security Kibana Dashboard</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes NGINX WAF (Part 1) — Ingress Hardening with Mod_Security and OWASP CRS]]></title>
            <link>https://medium.com/opensight-ch/kubernetes-nginx-waf-part-1-ingress-hardening-with-mod-security-and-owasp-crs-3cb1215cddfd?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/3cb1215cddfd</guid>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[crs]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Sat, 30 Apr 2022 06:32:16 GMT</pubDate>
            <atom:updated>2023-03-18T08:16:43.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tXVxr8cRhFNmaayW.png" /></figure><p><em>“Kubernetes Ingress with mod_security and OWASP”</em> — We show what all this means in today’s blog post.</p><blockquote>In today’s blog post, we’ll show you a way to keep malicious traffic off your Kubernetes cluster. We grab a topic from the technical magic box of the “Zero Trust” and immediately disenchant the technical jargon.</blockquote><blockquote>The goal is to setup Nginx Ingress and WAF properly in order to protect all web services</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xv-lLU31IgdXmdzp.png" /><figcaption><em>Image — Goal of this blog. A cyber security center for Kubernetes NGINX Controller WAF. Dashboard in Kibana</em></figcaption></figure><p>Mod_Security is an open source <strong>web application firewall (WAF)</strong> that is supported by various web servers (NGINX, Apache, IIS) and has existed since 2002. The OWASP organization provides a corresponding <strong>Core Rule Set (CRS)</strong> for the firewall, which keeps all kinds of malicious traffic out.</p><h4>Terms</h4><p>Kubernetes (also “K8s”) is an open source contrainducer orchestration engine originally developed by Google.</p><p>Here is an example of a simplified reference architecture, which is often found in a similar form — with deviations depending on the cloud provider. Incoming traffic is first routed via a load balancer (in our bare metal test cluster “MetalLB”) to one of the two Kubernetes nodes shown. An “NGINX Ingress Controller” ensures that an NGINX service (container) is run on each Kubernetes node, which acts as SSL termination and reverse proxy and then ultimately forwards the traffic to the correct container via a so-called “Kubernetes Service”. The web services / micro services are executed on the container. These micro services make sensitive data available and we therefore do not want to expose them to unfiltered web traffic — zero trust.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mr4vILLYFGebjNWn.jpg" /></figure><p>We would therefore like to start today with the NGINX service (in green) and examine the incoming traffic using a <strong>Web Application Firewall (WAF)</strong> in order to increase general security in the cluster. We are using the open source WAF called “mod_security” and will be using the <strong>Open Web Application Security Project (OWASP)</strong> <a href="https://github.com/coreruleset/coreruleset/">Core Ruleset (CRS)</a> against which we will inspect incoming traffic.</p><p>Incidentally, in the case of Microsoft Azure, the “<a href="https://azure.microsoft.com/de-de/services/web-application-firewall/#features">Azure Web Application Firewall</a>” service is offered, which is also based on the OWASP rulesets described in this blog. The pricing of the Azure Service can be found on the linked website.</p><h4>Open Web Application Security Project (OWASP)</h4><p>The <a href="https://owasp.org/">OWASP</a> ModSecurity Core Rule Set (CRS) is a freely accessible collection of “Detection Rules” — i.e. rules that can be used to examine incoming traffic. These rules can then be used in combination with a compatible web application firewall such as Mod_Security.</p><p>The “Core Rule Set” was developed with the aim of protecting web applications from a wide range of known attacks, including the “<a href="https://owasp.org/www-project-top-ten/">OWASP Top Ten</a>”. This is a top 10 list of the most frequently occurring security risks and security gaps in web applications, which is redefined every 3 years.<br>The core rule set currently contains rules that protect our web services from the following risks:</p><ul><li>SQL Injection (SQLi)</li><li>Cross Site Scripting (XSS)</li><li>Local File Inclusion (LFI)</li><li>Remote File Inclusion (RFI)</li><li>PHP Code Injection</li><li>Java Code Injection HTTPoxy</li><li>Shellshock</li><li>Unix/Windows Shell Injection</li><li>Session Fixation</li><li>Scripting/Scanner/Bot Detection</li><li>Metadata/Error Leakages</li></ul><h4>Houston, we have a problem</h4><p>First of all, as a test, we send an HTTP request to one of our test web services. We design the request in such a way that it clearly looks like an <a href="https://de.wikipedia.org/wiki/SQL-Injection">SQL injection attack</a>. You can also test this yourself with one of your own existing web services — we’ll just pretend that our micro service has a “users” endpoint and send an example SQL injection (“ExampleSQLInjection’ — “). For this we use the well-known tool “Postman”. As you can see, we get a Swagger document from the Micro Service in response — so the traffic was sent unfiltered to the Micro Service — Houston, we have a problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wxiU0vidtHEgDeww.png" /></figure><h4>Beam me up, Scotty</h4><p>To increase security, we are now making a few changes to the NGINX ingress controller in Kubernetes.<br>We edit the config map of our NGINX Ingress Controller in Kubernetes and activate “mod_security”, as well as the OWASP CRS (Open Web Application Security Project — Core Rule Set). <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#modsecurity">According to the documentation</a>, with the help of the “modsecurity-snippet” line, we can write a few lines in the nginx.conf (“modsecurity_rule”) so that the engine is actually activated. (By default, the engine otherwise only runs in “DetectionOnly” mode).</p><pre>kubectl edit configmap openzilla-ingress-ingress-nginx-controller -n ingress-nginx<br>...<br>#<br>apiVersion: v1<br>data:<br>  enable-modsecurity: &quot;true&quot;<br>  enable-owasp-modsecurity-crs: &quot;true&quot;<br>  modsecurity-snippet: |-<br>    SecRuleEngine On<br>    SecRequestBodyAccess On<br>    SecAuditLog /var/log/modsecurity_audit.log<br>    SecAuditLogParts ABCIJDEFHZ<br>    SecAuditEngine RelevantOnly<br>kind: ConfigMap<br>metadata:<br>  annotations:<br>....</pre><p>PS: If desired, you can also define your own Mod_Security Rules in the ConfigMap, such as whitelisting an IP address you know: “<strong>SecRule REMOTE_ADDR “@streq 192.168.254.1” \allow,phase:1,nolog</strong>” or deactivate existing rules .</p><p>If we now connect to one of our NGINX Ingress Controller Pods in Kubernetes, we will find the core rule set under “/etc/nginx/owasp-modsecurity-crs” (here the corresponding <a href="https://github.com/coreruleset/coreruleset">GIT repository</a>). In the nginx.conf we see that the corresponding config file has also been included:</p><pre>...<br>modsecurity_rules_file /etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf;<br>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ttJY2UE_V15Ezuu.png" /></figure><p>That looks good — now let’s run the above test again with Postman.<br>The traffic to the web service has now already been stopped by NGINX Ingress and Mod_Security — beautiful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0wFsZP5Pcy9GmaFZ.png" /></figure><p>If we check the Mod_Security log file, we see that the request was blocked because an SQL injection was detected according to rule “942100” from the CRS <a href="https://github.com/coreruleset/coreruleset/blob/v3.4/dev/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf">(REQUEST-942-APPLICATION-ATTACK-SQLI.conf)</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f3TF3JSeotarlojU.png" /></figure><p>That was the basic config of the Kubernetes NGINX Ingress Controller. More configurations for Log Ingestion into Elasticsearch and Dashboard Creation in our next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cb1215cddfd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/kubernetes-nginx-waf-part-1-ingress-hardening-with-mod-security-and-owasp-crs-3cb1215cddfd">Kubernetes NGINX WAF (Part 1) — Ingress Hardening with Mod_Security and OWASP CRS</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT — Semantic versioning and conventional commits]]></title>
            <link>https://medium.com/opensight-ch/git-semantic-versioning-and-conventional-commits-564aece418a0?source=rss----d8d441ca6b25---4</link>
            <guid isPermaLink="false">https://medium.com/p/564aece418a0</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[conventional-commits]]></category>
            <category><![CDATA[semantic-release]]></category>
            <dc:creator><![CDATA[roman]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 06:59:54 GMT</pubDate>
            <atom:updated>2023-03-18T08:16:27.110Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wLtLcbMGTpAuKUHJ.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/0*2V3p84ZuyQwltIdF.png" /></figure><p>GIT is an open source versioning tool and today belongs in every computer scientist’s toolbox. Today’s blog post is about automatic versioning of software projects.</p><blockquote>Imagine you create a git commit with the message: “fix: fix issue in login form”<br>Your CICD pipeline automatically recognizes that it is a bug fix (“fix:”) and therefore increases the software version from 1.3.5 to 1.3.6 and creates a release in the GIT repository accordingly. An entry is automatically made in the changelog. Everything is correctly versioned. Today’s blog post is all about this automatism.</blockquote><blockquote>opensight.ch — roman huesler</blockquote><p>If you are looking for general GIT training, I can recommend <a href="https://codewithmosh.com/courses">Mosh Hammedani’s online course</a>. Today’s blog post is not about the explanation and operation of the GIT tool, but more about the best practices and design in relation to the commit messages and the version tags of a GIT repository.</p><p>A large part of the community relies on “conventional commits” and “semantic releases” for versioning. This results in the following advantages, which we will now discuss in more detail:</p><ul><li>Automatic generation of CHANGELOGs</li><li>Automatic generation of the next semantic version number<br>(based on commit type “fix”, “feat”, “chore”)</li><li>Teammates instantly recognize the change type (“fix”, “feat”, “docs”, etc)</li><li>Automatic build triggering and better integration with CICD pipelines</li><li>Better understanding of the version history and thus easier collaboration</li></ul><h4>Contents</h4><ul><li><a href="#badsample">Example: Bad Version History</a></li><li><a href="#whento">When to create a Commit</a></li><li><a href="#semrel">Semantic Releases</a></li><li><a href="#concom">Conventional Commits</a></li><li><a href="#cicdv">Versioning in CI/CD Pipelines</a></li></ul><h4>Example: Bad Version History</h4><blockquote>A look at my older GIT repositories and commits made me take a closer look at the standards and best practices. A comprehensible version history / comprehensible commit messages serve for better understanding, traceability and facilitate cooperation with other developers.</blockquote><blockquote>opensight.ch — roman hüsler</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*AKInAarEGyuY3qIu.png" /><figcaption><em>Image — Bad Practice in GIT Version History</em></figcaption></figure><p>To further demonstrate what today’s blog post is about, here is an example of a bad GIT version history. The commit messages give little information about what has changed in each case.</p><h4>When to create a commit</h4><p>When should a commit be created at all?<br>A commit should be created whenever a unit of work is complete. For example, integrating a new feature, updating the documentation, fixing a bug. Also, different changes that are not directly related to each other should not be combined in one commit.</p><p>In the picture (above) you can see two commit messages:</p><ul><li>added google maps feature</li><li>bugfix in google maps feature</li></ul><p>These actions are part of the same “unit of work” and should therefore be squashed together.</p><h4>Semantic Releases</h4><pre># Creation of an annotated tag<br>git tag -a v2.0.0 -m &quot;Release v2.0.0 (2021-12-12)&quot;</pre><p>With “Annotated GIT Tags” you can tag your commits in GIT and provide them with a message. A Semantic Release consists of an annotated tag whose formatting has been defined according to the <a href="https://semver.org/">Semantic Versioning Specification</a>. The message usually also mentions all changes since the last release.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ju3oc4iBRkvpbs8m.png" /><figcaption><em>Image — Example Semantic Release of GIT Repository “semantic-release/semantic-release”</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/0*KEvyZmEdEAs-3YZu.png" /></figure><p>A <strong>semantic version</strong> consists of at least 3 components:</p><ul><li><strong>Major Release</strong><br>If a “breaking change” is introduced, the major release number must be increased</li><li><strong>Minor Release</strong><br>New features have been introduced, which are backwards compatible (no “breaking changes”)</li><li><strong>Patch Release</strong><br>Bugfixes (no “breaking changes”)</li></ul><p>So let’s create a semantic release as an example: We currently have version “1.7.45” and have made “breaking changes”. So we have to create a new “major release” for the next version (2.0.0).</p><p>First, we generate a list of all commits made since the last release:</p><pre>git log --pretty=format:%s v1.7.45...HEAD --no-merges</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-axPtlPh-i9kzhxZ.png" /><figcaption><em>Image — Changes / Commits from GIT Repository since last release</em></figcaption></figure><p>We now copy the list of changes since the last release (picture above) and create a new release accordingly.</p><pre>git tag -a v2.0.0</pre><p>We note all changes in the tag message. In addition, we enter the same changes in the CHANGELOG.md file.</p><pre>Release v2.0.0 (2021-12-12)<br><br>- feat!: upgrade to node 17<br>- fix: fix the bug with logfile generation</pre><p>Everything we have now done manually — calculating the next version number, formatting the annotated GIT tag, keeping the changelog — all this can also be done automatically (automatic versioning) using <a href="https://github.com/semantic-release/semantic-release">semantic release</a>. This is described in more detail in the “<a href="#cicdv">Versioning in CI/CD Pipelines</a>” chapter.</p><h4>Conventional Commits</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p0G6iD8MoRjuYaak.png" /><figcaption><em>Image — GIT Version History formatted according to “conventional commit</em>”</figcaption></figure><p>In order to make the GIT version history more understandable, the community has agreed on a standard (“conventional commits”), which can be found in many repositories today. Automatic versioning of the software projects is made possible by the fact that the type of change (patch, minor release, major release) can be derived directly from the commit message.</p><p>We only briefly describe the formatting of a conventional commit here. Check out the details on the <a href="https://www.conventionalcommits.org/en/v1.0.0/">home page</a> (www.conventionalcommits.org).</p><p><strong>Format</strong></p><pre>&lt;type&gt;[optional scope]: &lt;description&gt;<br><br>[optional body]<br><br>[optional footer(s)]</pre><p><strong>Example</strong></p><pre>feat(api)!: send confirmation email to the customer<br><br>BREAKING CHANGE: send an email to customer after order<br><br>Reviewed-by: Z<br>Refs: #123</pre><p><strong>Header</strong><br>The commit header first describes the type of change: fix, feat, chore, docs, refactor, perf.<br>In addition, a brief description of the changes made.</p><p><strong>Message Body</strong><br>Since this is a “breaking change” in this case, an “!” attached. In addition, the message says “BREAKING CHANGE”. This later helps the “semantic version” automatism to recognize that it is a major release.</p><h4>Versioning in CI/CD Pipelines</h4><p>Now we want to implement automatic versioning for a Node.JS project in a CI/CD pipeline on Gitlab. The idea is that we push a commit (conventional commit) to the Gitlab repository and through it. the CI/CD pipeline is initiated. As part of the CI/CD pipeline, the next version number of the software is generated. Some files are adjusted (package.json, Changelog.md) and automatically written to the GIT repository by the bot.</p><p>First we create an NPM project and install some dependencies:</p><pre>npm init --yes<br>npm install --save-dev @semantic-release/changelog<br>npm install --save-dev @semantic-release/commit-analyzer<br>npm install --save-dev @semantic-release/exec<br>npm install --save-dev @semantic-release/git<br>npm install --save-dev @semantic-release/gitlab<br>npm install --save-dev @semantic-release/npm<br>npm install --save-dev @semantic-release/release-notes-generator</pre><p>Then we edit the package.json and add the following lines:</p><pre>&quot;private&quot;: true,<br>&quot;release&quot;: {<br>    &quot;plugins&quot;: [<br>      &quot;@semantic-release/commit-analyzer&quot;,<br>      &quot;@semantic-release/release-notes-generator&quot;,<br>      &quot;@semantic-release/changelog&quot;,<br>      &quot;@semantic-release/npm&quot;,<br>      [<br>        &quot;@semantic-release/exec&quot;,<br>        {<br>          &quot;prepareCmd&quot;: &quot;sed &#39;s/\&quot;app_version\&quot;.*/\&quot;app_version\&quot;:\&quot;${nextRelease.version}\&quot;/&#39; src/configuration.json &gt; configuration.json&quot;<br>        }<br>      ],<br>      [<br>        &quot;@semantic-release/git&quot;,<br>        {<br>          &quot;assets&quot;: [<br>            &quot;package.json&quot;,<br>            &quot;CHANGELOG.md&quot;,<br>            &quot;configuration.json&quot;<br>          ],<br>          &quot;message&quot;: &quot;chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}&quot;<br>        }<br>      ],<br>      &quot;@semantic-release/gitlab&quot;<br>    ]<br>},<br>&quot;branches&quot;: [<br>  &quot;master&quot;<br>]</pre><p>These lines determine what happens when the Semantic Versioning Tool (“npx semantic-release”) is run later.<br>A brief explanation of all plugins used:</p><ul><li><strong>commit-analyzer</strong><br>The commit analyzer analyzes our commit message. This should be formatted according to the “Conventional Commit” specification. Based on the message, the tool then decides on a patch release, minor release, or major release for the next version.</li><li><strong>release-notes-generator</strong><br>The Release Notes Generator collects all changes since the last commit (commit log)</li><li><strong>changelog</strong><br>Writes the release notes (release-notes-generator) to a file CHANGELOG.md</li><li><strong>npm</strong><br>Writes the next version number to the NPM project’s package.json file</li><li><strong>exec</strong><br>Execute any command. In the example (above) we write the next version number with “sed” in the file “configuration.json”</li><li><strong>git</strong><br>With the GIT plugin, the changes made can be committed to the GIT repository. So we commit the customized package.json, the generated CHANGELOG.md, and the configuration.json we just generated</li><li><strong>gitlab</strong><br>The Gitlab plugin now pushes all changes to the Gitlab repository.</li></ul><p><strong>Note — Gitlab plugin</strong><br>In order for the Gitlab plugin to work, the access token should be stored in the Gitlab repository. The token should have “api” and “write_repository” permission</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fisgmpUNR2MpZ4M6.png" /></figure><p>Now we add the “.gitlab-ci.yml” file to the project, i.e. the definition of the Gitlab CI/CD pipeline.</p><pre>stages:<br>  - release<br><br>semantic_release:<br>  image: node:latest<br>  stage: release<br>  only:<br>    - master<br>  script:<br>    - npm i<br>    - npx semantic-release<br>  artifacts:<br>    paths:<br>      - configuration.json</pre><p>If we now make and commit a change in the Git repository, the CI/CD pipeline is automatically executed, which generates a new version number.</p><pre>git add testfile.txt<br>git commit -m &quot;fix: fix bug in semantic release&quot;<br>git push origin master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jOrAfxn09w8G_kxz.png" /><figcaption><em>Image — CHANGELOG.md</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oLIjiOUhg-sIwucj.png" /><figcaption><em>Bild — Gitlab Repository Release</em></figcaption></figure><p>After checking in the code, the CI/CD pipeline was executed and the bot automatically adjusted the files (“CHANGELOG.md”, “package.json”, “configuration.json”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2hA0KpmeUIkboDzV.png" /><figcaption><em>Image — Automatic adjustment of the version number and Gitlab release by semantic-release-bot</em></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=564aece418a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/opensight-ch/git-semantic-versioning-and-conventional-commits-564aece418a0">GIT — Semantic versioning and conventional commits</a> was originally published in <a href="https://medium.com/opensight-ch">opensight.ch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>