<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ansible on CTRL-Find</title>
    <link>https://ctrl-find.nl/tags/ansible/</link>
    <description>Recent content in Ansible on CTRL-Find</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 25 Apr 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://ctrl-find.nl/tags/ansible/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Advanced Ansible: Collections&#43;</title>
      <link>https://ctrl-find.nl/posts/ansible_collections/</link>
      <pubDate>Fri, 25 Apr 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_collections/</guid>
      <description>&lt;p&gt;A set of modules together is a called a collection. Like ansible.builtin.&#xA;I&amp;rsquo;ve used collections in the past to use the modules it provided but never really created them.&#xA;In this post I want to take you on my journery to learn more about these collections.&lt;/p&gt;&#xA;&lt;p&gt;To create a collection we need to do the following:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;div style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&#xA;&lt;table style=&#34;border-spacing:0;padding:0;margin:0;border:0;&#34;&gt;&lt;tr&gt;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;1&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;2&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;3&#xA;&lt;/span&gt;&lt;span style=&#34;white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f&#34;&gt;4&#xA;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;vertical-align:top;padding:0;margin:0;border:0;;width:100%&#34;&gt;&#xA;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ansible-galaxy collection init &amp;lt;namespace name&amp;gt;.&amp;lt;collection name&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#6272a4&#34;&gt;# EXAMPLE:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ansible-galaxy collection init local.random&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;/div&gt;&lt;p&gt;This will build the scaffold collection.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Advanced Ansible: Custom modules</title>
      <link>https://ctrl-find.nl/posts/ansible_custom_modules/</link>
      <pubDate>Sat, 12 Apr 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_custom_modules/</guid>
      <description>&lt;p&gt;This is my first time trying to create a Ansible custom module.&#xA;I dont have much python knowledge (the very bare minimum), but I want to expand my knowledge of python and Ansible by creating a custom module.&lt;/p&gt;&#xA;&lt;h3 id=&#34;what-do-we-need&#34;&gt;What do we need?&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Installed:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Ansible&lt;/li&gt;&#xA;&lt;li&gt;Python3&lt;/li&gt;&#xA;&lt;li&gt;virtual environment for python3 packages&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;A folder to place our files&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;starting-with-the-module&#34;&gt;Starting with the module&lt;/h3&gt;&#xA;&lt;p&gt;Activate the virtual environment and create a folder called library.&#xA;Ansible knows that if there is a custom module its in the library folder.&#xA;In this library folder we can create our python file, I&amp;rsquo;ve called mine &lt;code&gt;pokemon_api.py&lt;/code&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Testing Ansible code</title>
      <link>https://ctrl-find.nl/posts/ansible_testing/</link>
      <pubDate>Sat, 15 Mar 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_testing/</guid>
      <description>&lt;h2 id=&#34;what-is-ansible-molecule&#34;&gt;What is Ansible Molecule&lt;/h2&gt;&#xA;&lt;p&gt;Ansible Molecule is created for development and testing of Ansible roles and collections.&#xA;Through Molecule it is possible to test against different OS versions or complete new systems.&lt;/p&gt;&#xA;&lt;h2 id=&#34;prerequisites-to-local-use-molecule&#34;&gt;prerequisites to local use Molecule:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Podman of docker installation&lt;/li&gt;&#xA;&lt;li&gt;Locally installed ansible&lt;/li&gt;&#xA;&lt;li&gt;Python3&lt;/li&gt;&#xA;&lt;li&gt;A python virtual environment&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;&#xA;&lt;p&gt;There are different ways of installing Ansible Molecule see this &lt;a href=&#34;https://ansible.readthedocs.io/projects/molecule/installation/&#34;&gt;url&lt;/a&gt;.&#xA;I Chose the pip way with &lt;code&gt;python3 -m pip install molecule ansible-core&lt;/code&gt;.&#xA;Whether we choose docker or podman we need to install the molecule connector, I personally use podman so thats &lt;code&gt;pip install molecule-podman&lt;/code&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Ansible secrets</title>
      <link>https://ctrl-find.nl/posts/ansible_secrets/</link>
      <pubDate>Tue, 11 Feb 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_secrets/</guid>
      <description>&lt;h2 id=&#34;ansible-vault&#34;&gt;Ansible-vault?!&lt;/h2&gt;&#xA;&lt;p&gt;Always wondered how to use ansible with sensitive information like secrets,files,variables or configurations?&#xA;Thats where ansible-vault comes to play, this is a way to encrypt the data with a password.&lt;/p&gt;&#xA;&lt;p&gt;There are two ways to use ansible-vault, with cli parameters or use a password file.&#xA;We will explorer both options below.&lt;/p&gt;&#xA;&lt;h2 id=&#34;how-to-use-the-cli-parameters&#34;&gt;How to use the CLI parameters&lt;/h2&gt;&#xA;&lt;p&gt;The CLI parameters variant asks for a password that you want to use for en/decrypt or view the encrypted content.&#xA;I have created a file named in /Users/sebas/Desktop/ansible/supersecret.yml with the following content in it:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Creating Ansible Roles</title>
      <link>https://ctrl-find.nl/posts/ansible_roles/</link>
      <pubDate>Mon, 20 Jan 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_roles/</guid>
      <description>&lt;h3 id=&#34;why-roles-over-playbooks&#34;&gt;Why Roles over Playbooks?&lt;/h3&gt;&#xA;&lt;p&gt;Single playbooks are great for tasks but when a project starts getting complexer, it way more managable in a role then a single playbook.&#xA;Ansible role is a predefined set of playbooks that is build for a specific purpose.&#xA;All the necessary configurations can be set and build into the role.&lt;/p&gt;&#xA;&lt;h3 id=&#34;creating-the-role&#34;&gt;Creating the role&lt;/h3&gt;&#xA;&lt;p&gt;We create the role in the folder we&amp;rsquo;ve been using in the previous parts &lt;code&gt;/Users/sebas/Desktop/ansible&lt;/code&gt;.&#xA;With following command we can create a pre-setup role through ansible.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Creating Ansible Playbooks</title>
      <link>https://ctrl-find.nl/posts/ansible_playbooks/</link>
      <pubDate>Mon, 13 Jan 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_playbooks/</guid>
      <description>&lt;h4 id=&#34;why-playbooks-over-adhoc-commands&#34;&gt;Why Playbooks over ADHOC commands&lt;/h4&gt;&#xA;&lt;p&gt;ADHOC commands are great for short and quick informational actions but when you want to to get more information or configuration from a group.&lt;br&gt;&#xA;Then is one command at a time a really time consuming action, this is where playbooks shine.&lt;br&gt;&#xA;Why are playbook better then adhoc commands?, there is more predictablity on playbooks and less manual work on it.&lt;/p&gt;&#xA;&lt;p&gt;A playbook is a repeatable script that we can run over and over again, with the same result.&#xA;In these playbooks we can specify precise actions what we want to do and in which order.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Managing Hosts with Ansible</title>
      <link>https://ctrl-find.nl/posts/ansible_hosts/</link>
      <pubDate>Tue, 07 Jan 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible_hosts/</guid>
      <description>&lt;h3 id=&#34;what-do-we-need&#34;&gt;What do we need?&lt;/h3&gt;&#xA;&lt;p&gt;There are a few things we need to start with managing hosts with ansible.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;SSH keys&lt;/li&gt;&#xA;&lt;li&gt;Place to store our files&lt;/li&gt;&#xA;&lt;li&gt;Inventory file&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;creating-ssh-key&#34;&gt;Creating SSH key&lt;/h3&gt;&#xA;&lt;p&gt;To manage hosts, we need to use a SSH key. We can create them with the following command: &lt;code&gt;ssh-keygen -t ed25519&lt;/code&gt;. Choose where the SSH files needs to be placed and if you want to use a password or not (much more secure if you do).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Ansible? what is that!</title>
      <link>https://ctrl-find.nl/posts/ansible/</link>
      <pubDate>Mon, 06 Jan 2025 00:00:00 +0000</pubDate>
      <guid>https://ctrl-find.nl/posts/ansible/</guid>
      <description>&lt;p&gt;Ansible is a configuration management tool that can be used for configuring servers, clients and network equipment.&lt;br&gt;&#xA;The basic way of using this tool is through &lt;strong&gt;SSH&lt;/strong&gt;, utilizing passwords or preferably SSH keys.&lt;br&gt;&#xA;In this series we will be using Ansible for configuring a server through the following options;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;ansible-commands&lt;/strong&gt;: Execute single command on a host&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;ansible-playbooks&lt;/strong&gt;&amp;quot;: Run repeatable script(s) on a host&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;ansible-roles&lt;/strong&gt;: Organize and reuse code for configurations tasks&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;There is a newer version called &lt;strong&gt;ansible-navigator&lt;/strong&gt; that&amp;rsquo;s for another post, for now lets stick to the current version called &lt;strong&gt;ansible&lt;/strong&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
