<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Guilherme Diniz</title>
    <description>The latest articles on Forem by Guilherme Diniz (@gsdiniz).</description>
    <link>https://forem.com/gsdiniz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1177338%2Fc653985a-e0f1-48b1-992b-e216a97daf95.jpeg</url>
      <title>Forem: Guilherme Diniz</title>
      <link>https://forem.com/gsdiniz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gsdiniz"/>
    <language>en</language>
    <item>
      <title>Automating RKE2 and Rancher Deployments with Ansible</title>
      <dc:creator>Guilherme Diniz</dc:creator>
      <pubDate>Wed, 08 Oct 2025 19:54:22 +0000</pubDate>
      <link>https://forem.com/gsdiniz/automating-rke2-and-rancher-deployments-with-ansible-4gb3</link>
      <guid>https://forem.com/gsdiniz/automating-rke2-and-rancher-deployments-with-ansible-4gb3</guid>
      <description>&lt;p&gt;Modern infrastructure management is all about automation. The more we can replace manual steps with reliable, repeatable code, the easier it becomes to scale and maintain complex environments. One of the most powerful tools for this task is Ansible.&lt;/p&gt;




&lt;p&gt;In this post, I’ll explain what Ansible is, why it matters, and how I’ve used it to automate the deployment of RKE2 (Rancher Kubernetes Engine 2) and Rancher, creating a reproducible and streamlined setup.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What is Ansible?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.ansible.com/" rel="noopener noreferrer"&gt;Ansible&lt;/a&gt; is an open-source automation tool that allows you to manage systems, deploy applications, and orchestrate IT environments using simple, human-readable configuration files called playbooks.&lt;/p&gt;

&lt;p&gt;Some key concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Agentless: Unlike many configuration management tools, Ansible does not require any agent running on target nodes. It connects via SSH.&lt;/li&gt;
&lt;li&gt;Idempotency: Running the same playbook multiple times will always bring the system to the desired state, without introducing unwanted changes.&lt;/li&gt;
&lt;li&gt;Infrastructure as Code (IaC): Your infrastructure configuration is stored in version control, making it transparent, shareable, and auditable.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What the Project Does&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The repository &lt;a href="https://github.com/gsdiniz/ansible-rke-rancher" rel="noopener noreferrer"&gt;ansible-rke-rancher&lt;/a&gt; provides &lt;strong&gt;Ansible playbooks&lt;/strong&gt; to:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Provision RKE2 (Kubernetes)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automates installation of the RKE2 components across master and worker nodes.&lt;/li&gt;
&lt;li&gt;Handles the cluster configuration and setup consistently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Deploy Rancher&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installs Rancher, a popular Kubernetes management platform, on top of the cluster.&lt;/li&gt;
&lt;li&gt;Simplifies cluster lifecycle management with a centralized UI and APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Infrastructure Automation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses Ansible inventory to define your nodes (masters and workers).&lt;/li&gt;
&lt;li&gt;Runs repeatable tasks for installing dependencies, configuring users, and setting up the environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, the project takes what would normally be a complex, error-prone set of manual steps and turns it into a single automated workflow.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Why This Matters&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Deploying Kubernetes manually can be time-consuming and difficult, especially if you need consistency across multiple environments (e.g., dev, staging, and production). By leveraging Ansible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You gain repeatability — the same playbook works across environments.&lt;/li&gt;
&lt;li&gt;You improve scalability — adding new nodes or clusters is easier.&lt;/li&gt;
&lt;li&gt;You reduce human error — no more missed configuration steps.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Get Started&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You can explore the project here:&lt;br&gt;
👉 GitHub: &lt;a href="https://github.com/gsdiniz/ansible-rke-rancher" rel="noopener noreferrer"&gt;ansible-rke-rancher&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The repository includes playbooks and instructions to help you quickly bootstrap a Rancher-managed RKE2 cluster using Ansible.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;What the repo is / goals&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It’s an Ansible playbook set to configure an RKE2 cluster and install Rancher on it using a custom root CA.&lt;/li&gt;
&lt;li&gt;Tested on EL-family Linux distros (Rocky Linux 9 etc.)&lt;/li&gt;
&lt;li&gt;Presumes some prerequisites: public SSH keys in hosts, Internet connectivity, that a custom CA is already set up, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the basic idea is: you point Ansible at some hosts (masters + workers), it sets up RKE2 cluster, then installs Rancher with TLS (with your own certs), to give you a usable Kubernetes + Rancher deployment in an automated, repeatable way.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Core structure: inventory, playbooks, roles&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here are the main parts of the repo (and what they do):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;inventory/hosts.yml&lt;/code&gt; Defines the nodes: IPs, hostnames, roles (masters / workers) over which Ansible will run.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;playbook/&lt;/code&gt; Contains two main playbooks: one for initializing / building the cluster (init-cluster.yml) and one for installing Rancher (install-rancher.yml) after the cluster is up.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ansible.cfg&lt;/code&gt; Configuration for Ansible – SSH settings, privilege escalation, etc. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;requirements.yml&lt;/code&gt; Declares any Ansible roles / collections needed (external dependencies)&lt;/p&gt;

&lt;p&gt;Within the playbooks, there are roles that divide up the work. According to the README, the RKE2 related work is divided into these roles:_ Init, Principal, Masters, Agents_.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What the roles do&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s what each role is responsible for (based on the README and code):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Init&lt;br&gt;
Runs on all hosts. Prepares the base environment so the RKE2 cluster can function. Tasks include: configuring firewall (firewalld), kernel modules, updating packages, ensuring things needed generally are in place. These tasks ensure consistency and that preconditions are met.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Principal&lt;br&gt;
The “principal master” node is like the first control-plane node. This node gets some extra services installed (beyond what other masters get), because Rancher + RKE2 needs a control-plane to bootstrap from.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Masters&lt;br&gt;
All other master nodes (i.e. not the principal one) or nodes you later add as masters. They will join the cluster, obtaining necessary tokens (node-token etc.) from the principal node. Their configuration is done so that they are control-plane nodes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Agents&lt;br&gt;
The worker nodes. They join the cluster as agents (workers). They get the node token, and the necessary configuration to communicate with the cluster. (GitHub)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After RKE2 cluster is up (i.e. masters + agents are configured), there’s a separate playbook to install Rancher:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;install-rancher.yml&lt;/em&gt;
This playbook takes care of installing Rancher on top of the RKE2 cluster. It uses certificates from a certs/tls-rancher folder: you supply a CA, internal CA, additional CA trust, the Rancher TLS key/cert, etc. (GitHub)&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Key configuration aspects you can control, via variables / inventory, include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which hosts are masters vs workers. The inventory file allows specifying which hosts are in each group.&lt;/li&gt;
&lt;li&gt;Which host is the “principal master”. The role “Principal” is used for that specific host. This is needed for bootstrapping.&lt;/li&gt;
&lt;li&gt;TLS certs: you bring your own certificate authority root, and your own TLS certs for Rancher’s HTTPS endpoint. The playbook expects them in certain paths.&lt;/li&gt;
&lt;li&gt;OS distribution is expected to be RHEL/Oracle/SUSE/Alma/Rocky‐Linux etc.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Sequence / workflow&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s the order in which things happen, roughly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define your hosts in inventory/hosts.yml. Specify which hosts are masters, which are workers. Also mark one host as principal/master (probably via group vars).&lt;/li&gt;
&lt;li&gt;Make sure prerequisites are met: SSH access, custom CA, certs in place, OS versions, etc.&lt;/li&gt;
&lt;li&gt;Run the cluster init:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible-playbook -i inventory/hosts.yml playbook/init-cluster.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This runs the Init role on all hosts&lt;/li&gt;
&lt;li&gt;On principal: runs Principal role&lt;/li&gt;
&lt;li&gt;On other masters: Masters&lt;/li&gt;
&lt;li&gt;On agents/workers: Agents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That sets up RKE2, ensures control-plane, etc.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once the cluster is up, prepare the certs for Rancher: in certs/tls-rancher you have CA root, internal CA, etc.&lt;/li&gt;
&lt;li&gt;Then run:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible-playbook -i inventory/hosts.yml playbook/install-rancher.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This installs Rancher on the cluster, using the TLS certificates you provided, integrating with the custom CA where needed.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Infrastructure automation is not just a convenience — it’s a necessity for modern DevOps and cloud-native teams. With tools like Ansible, we can codify best practices, enforce consistency, and focus more on delivering value instead of fighting configuration drift.&lt;/p&gt;

&lt;p&gt;This project is a step toward that goal: automating Kubernetes cluster provisioning and Rancher deployment with Ansible.&lt;/p&gt;

&lt;p&gt;If you’re interested in Kubernetes, Rancher, or Ansible, I encourage you to check out the repo, try it out, and even contribute!&lt;/p&gt;




&lt;p&gt;Via &lt;a href="https://medium.com/@gsdiniz1990/automating-rke2-and-rancher-deployments-with-ansible-c2325556f26b" rel="noopener noreferrer"&gt;Guilherme Diniz&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>rancher</category>
      <category>rke2</category>
    </item>
    <item>
      <title>Why Your Company Should Use a Self-Signed Internal CA for TLS Certificates</title>
      <dc:creator>Guilherme Diniz</dc:creator>
      <pubDate>Wed, 08 Oct 2025 14:47:08 +0000</pubDate>
      <link>https://forem.com/gsdiniz/why-your-company-should-use-a-self-signed-internal-ca-for-tls-certificates-307n</link>
      <guid>https://forem.com/gsdiniz/why-your-company-should-use-a-self-signed-internal-ca-for-tls-certificates-307n</guid>
      <description>&lt;p&gt;&lt;em&gt;“Wait — why do we need our own certificate authority inside the company?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you’re a new developer or DevOps engineer, this is a common and important question when working in secure internal environments.&lt;/p&gt;

&lt;p&gt;Let’s break it down.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The Challenge: Securing Internal Applications&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In most organizations, internal web applications — such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;my-system.company.local&lt;/li&gt;
&lt;li&gt;intranet.company.local&lt;/li&gt;
&lt;li&gt;grafana.company.local&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;— need to communicate securely via HTTPS.&lt;/p&gt;

&lt;p&gt;Even though these apps are not publicly accessible, modern browsers, frameworks, and APIs expect encrypted traffic. So, TLS is mandatory.&lt;/p&gt;

&lt;p&gt;But using public CAs (like Let’s Encrypt or DigiCert) comes with problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internal domains like .local or .company.local aren’t valid on the public internet.&lt;/li&gt;
&lt;li&gt;You can’t prove ownership of them to a public CA.&lt;/li&gt;
&lt;li&gt;Renewing and managing multiple certificates manually is painful and risky.&lt;/li&gt;
&lt;li&gt;You’d be spending money for no external benefit.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;The Solution: Set Up an Internal Certificate Authority (CA)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Instead of relying on external providers, you can create a self-signed internal CA— a trusted root certificate that lives only inside your organization.&lt;/p&gt;

&lt;p&gt;This internal CA will be the foundation to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sign TLS certificates for internal systems&lt;/li&gt;
&lt;li&gt;Manage lifecycle and trust&lt;/li&gt;
&lt;li&gt;Avoid browser warnings and TLS errors across your network&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it Works&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a root CA certificate (self-signed)&lt;/li&gt;
&lt;li&gt;Install the CA certificate into trusted stores on all internal machines&lt;/li&gt;
&lt;li&gt;Use the CA to issue individual TLS certs for your services&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Step-by-Step: Creating a Self-Signed CA and Issuing Certificates&lt;/p&gt;

&lt;p&gt;Here’s a minimal example using OpenSSL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Generate the Root CA Key and Certificate&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl genrsa -out internal-rootCA.key 4096
openssl req -x509 -new -nodes -key internal-rootCA.key \
 -sha256 -days 1825 -out internal-rootCA.crt \
 -subj "/C=BR/ST=SP/O=Company/CN=Internal CA"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Generate a Private Key and CSR for Your App&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl genrsa -out my-system.company.local.key 2048
openssl req -new -key my-system.company.local.key -out my-system.company.local.csr \
 -subj "/C=BR/ST=SP/O=Company/CN=my-system.company.local"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Create a SAN Config (Subject Alternative Name)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a file &lt;code&gt;san.cnf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[req]
distinguished_name=req
[ext]
subjectAltName=DNS:my-system.company.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Sign the CSR with Your Internal CA
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openssl x509 -req -in my-system.company.local.csr \
 -CA internal-rootCA.crt -CAkey internal-rootCA.key -CAcreateserial \
 -out my-system.company.local.crt -days 825 -sha256 \
 -extfile san.cnf -extensions ext

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

&lt;/div&gt;



&lt;p&gt;That’s it. You now have a valid TLS certificate signed by your own internal CA.&lt;/p&gt;




&lt;p&gt;Distribute and Trust Your CA&lt;/p&gt;

&lt;p&gt;To make this work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install the &lt;strong&gt;internal-rootCA.crt&lt;/strong&gt; on all developer machines, servers, and containers.&lt;/li&gt;
&lt;li&gt;For browsers and operating systems, import the CA into the &lt;em&gt;Trusted Root Certificates Store&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;In enterprise environments, automate this using GPO (Windows), Ansible, or MDMs (mobile device management).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;An internal CA gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complete control over your TLS infrastructure&lt;/li&gt;
&lt;li&gt;No cost or dependency on external providers&lt;/li&gt;
&lt;li&gt;A scalable way to secure internal services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s a foundational DevOps skill that pays off in reliability, compliance, and developer experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Setting up an internal CA is one of those “small infrastructure wins” that unlocks big benefits later. If you’re in DevOps, SRE, or backend engineering — it’s worth mastering.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Bonus: Automate Everything&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Manually managing certs gets old fast. Consider using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cfssl: Cloudflare’s PKI toolkit&lt;/li&gt;
&lt;li&gt;step-ca: Easy, production-ready CA server&lt;/li&gt;
&lt;li&gt;Vault PKI: Secret management with certificate issuing&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Via &lt;a href="https://blog.guilhermediniz.com.br/why-your-company-should-use-a-self-signed-internal-ca-for-tls-certificates-9d9fdab3f4f2" rel="noopener noreferrer"&gt;Guilherme Diniz&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>devops</category>
      <category>security</category>
      <category>tls</category>
    </item>
  </channel>
</rss>
