<?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: Thiago Laurito</title>
    <description>The latest articles on Forem by Thiago Laurito (@sl4ck).</description>
    <link>https://forem.com/sl4ck</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%2F306749%2F4648ac7c-cbaf-4644-ac45-b0ca085128fa.png</url>
      <title>Forem: Thiago Laurito</title>
      <link>https://forem.com/sl4ck</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sl4ck"/>
    <language>en</language>
    <item>
      <title>Lab HashStack - Part 2</title>
      <dc:creator>Thiago Laurito</dc:creator>
      <pubDate>Wed, 05 Feb 2020 20:11:49 +0000</pubDate>
      <link>https://forem.com/sl4ck/lab-hashstack-part-2-5g5p</link>
      <guid>https://forem.com/sl4ck/lab-hashstack-part-2-5g5p</guid>
      <description>&lt;p&gt;Let's prepare our environment with Vault and RabbitMQ.&lt;/p&gt;

&lt;p&gt;The Vault will do the Vault function and also provide Dynamic Secrets for both our RabbitMQ stack and our Cassandra DB stack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fybaqmujtq0wvgrihqnwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fybaqmujtq0wvgrihqnwj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will add the generated token in Consul to the Vault in 3 files:&lt;/p&gt;

&lt;p&gt;modules/vault/vault.tf -&amp;gt; Add token in "CONSUL_HTTP_TOKEN"&lt;/p&gt;

&lt;p&gt;Later add some token in:&lt;/p&gt;

&lt;p&gt;data/vault-server-01/config/vault-config.json&lt;/p&gt;

&lt;p&gt;data/vault-server-02/config/vault-config.json&lt;/p&gt;

&lt;p&gt;Both "Parameter Token".&lt;/p&gt;

&lt;p&gt;After that we will execute the module called vault cluster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply -target=module.vault_cluster
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See that it already appears registered at the Consul but with "Sealed" status.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpnexlh3dpwxny93nndod.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpnexlh3dpwxny93nndod.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's go to the Unseal process on Vault Server 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it vault-server-1 /bin/sh

vault operator init

vault operator unseal

vault status
Key             Value
---             -----
Seal Type       shamir
Initialized     true
Sealed          false
Total Shares    5
Threshold       3
Version         1.3.2
Cluster Name    vault-cluster-9be77481
Cluster ID      684b9232-19b4-9fb9-1b2e-8fd1ad08fdb7
HA Enabled      true
HA Cluster      https://10.5.0.2:8201
HA Mode         active
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's run the Unseal process on Vault Server 2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it vault-server-2 /bin/sh

vault operator unseal

vault status
Key                    Value
---                    -----
Seal Type              shamir
Initialized            true
Sealed                 false
Total Shares           5
Threshold              3
Version                1.3.2
Cluster Name           vault-cluster-9be77481
Cluster ID             684b9232-19b4-9fb9-1b2e-8fd1ad08fdb7
HA Enabled             true
HA Cluster             https://10.5.0.2:8201
HA Mode                standby
Active Node Address    http://10.5.0.2:8200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will prepare the image of rabbitmq in the docker with the acl generated in the Consul and then execute the build.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /redstack_terraform_public/docker-images/rabbitmq

vim config/rabbitmq.conf 

docker build -t rabbimq .

cd ../../redstack

vim modules/rabbitmq/rabbitmq.tf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add ACL Token "CONSUL_HTTP_TOKEN"&lt;/p&gt;

&lt;p&gt;After completing the build of the Docker image we will run the rabbitmq_cluster module.&lt;/p&gt;

&lt;p&gt;terraform apply -target=module.rabbitmq_cluster&lt;/p&gt;

&lt;p&gt;We can already see the Rabbitmq stack, our Queue manager at Consul.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkv1vlalrdwhcfqvyd6ye.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkv1vlalrdwhcfqvyd6ye.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The rabbitmq_runtime module has the function of creating an example queue called "hello" an administrator user to access RabbitMQ's Web management.&lt;/p&gt;

&lt;p&gt;It should be executed after deploying the rabbitmq_cluster module&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply -target=module.rabbitmq_runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's run the vault_rabbitmq_runtime module.&lt;/p&gt;

&lt;p&gt;The function of this module is to create on the Vault Server the feature Dynamic Secrets for random user on Rabbitmq.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply -target=module.vault_rabbitmq_runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After applying the vault_rabbitmq_runtime module we will test the feature.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it vault-server-1 /bin/sh

vault read rabbitmq/creds/rabbitmq_access_role
Key                Value
---                -----
lease_id           rabbitmq/creds/rabbitmq_access_role/Ff0fZcIj1SRAWeoQNHX21RzF
lease_duration     768h
lease_renewable    true
password           ea070a9f-9306-9f82-9cad-c42ab7553d02
username           root-bd54ff95-eec1-d07c-c966-6ad02ee725b4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See that the vault creates a username and password so that you can authenticate with Rabbitmq.&lt;/p&gt;

&lt;p&gt;And it has an expiration time that can be set according to your business.&lt;/p&gt;

&lt;p&gt;In the next Post we will deploy the Cassandra DB Stack with dynamic Secret active in the Vault and using the Consul as a Discovery service :)&lt;/p&gt;

</description>
      <category>devops</category>
      <category>security</category>
    </item>
    <item>
      <title>Multiple Terraform Versions</title>
      <dc:creator>Thiago Laurito</dc:creator>
      <pubDate>Thu, 16 Jan 2020 11:26:59 +0000</pubDate>
      <link>https://forem.com/sl4ck/multiple-terraform-versions-1g9n</link>
      <guid>https://forem.com/sl4ck/multiple-terraform-versions-1g9n</guid>
      <description>&lt;p&gt;When targeting IAC (Infrastructure as Code) with terraform we can find designs that use different versions of terraform.&lt;/p&gt;

&lt;p&gt;For scenarios like this we can use a tool written in GO called tfswitch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://warrensbox.github.io/terraform-switcher/"&gt;https://warrensbox.github.io/terraform-switcher/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>linux</category>
    </item>
    <item>
      <title>Lab HashStack - Part 1</title>
      <dc:creator>Thiago Laurito</dc:creator>
      <pubDate>Tue, 14 Jan 2020 19:52:50 +0000</pubDate>
      <link>https://forem.com/sl4ck/lab-hashstack-part-1-1472</link>
      <guid>https://forem.com/sl4ck/lab-hashstack-part-1-1472</guid>
      <description>&lt;p&gt;In this post the idea would be to set up a Lab for studies using Hashicorp solutions, such as &lt;a href="https://www.terraform.io/" rel="noopener noreferrer"&gt;Terraform&lt;/a&gt;, &lt;a href="https://www.vaultproject.io/" rel="noopener noreferrer"&gt;Vault&lt;/a&gt; and &lt;a href="https://www.consul.io/" rel="noopener noreferrer"&gt;Consul&lt;/a&gt; in the construction of Stack.&lt;br&gt;
We will use Consul with the Service Discovery feature and will also strengthen the security of our stack by using Acl's by restricting any attempts to access services below it without a valid token.&lt;br&gt;
The vault's role is to provide the login security of our Cassandra DB and Rabbitmq with the dynamic secrets feature.&lt;br&gt;
Traefik we will use to do load balancing between servers.&lt;br&gt;
The terraform remote state will be using Terraform Cloud.&lt;/p&gt;
&lt;h4&gt;
  
  
  Requirements:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Terraform 11.4&lt;/li&gt;
&lt;li&gt;Vault&lt;/li&gt;
&lt;li&gt;Consul&lt;/li&gt;
&lt;li&gt;Docker&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Step 1:
&lt;/h4&gt;

&lt;p&gt;Create Account Terraform Cloud.&lt;br&gt;
&lt;a href="https://www.terraform.io/docs/cloud/free/index.html" rel="noopener noreferrer"&gt;https://www.terraform.io/docs/cloud/free/index.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generate your Token:&lt;br&gt;
&lt;a href="https://app.terraform.io/app/settings/tokens" rel="noopener noreferrer"&gt;https://app.terraform.io/app/settings/tokens&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add on the home directory a file terraformrc with credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt; &amp;gt;~/.terraformrc
credentials "app.terraform.io" {
  token = "REPLACE_ME WITH TOKEN GENERATE"
}
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2
&lt;/h4&gt;

&lt;p&gt;Download the repository on github&lt;br&gt;
&lt;a href="https://github.com/laund/redstack_terraform_public" rel="noopener noreferrer"&gt;https://github.com/laund/redstack_terraform_public&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 3 - Deploy Stack
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform apply &lt;span class="nt"&gt;-target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;module.network

terraform apply &lt;span class="nt"&gt;-target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;module.traefik
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Access url &lt;a href="http://traefik.redstack.local:8081" rel="noopener noreferrer"&gt;http://traefik.redstack.local:8081&lt;/a&gt; in your browser for validate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6zxg69x6zsaaoiyvymvp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6zxg69x6zsaaoiyvymvp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After validation we follow with the deployment of Consul.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply -target=module.consul_cluster

docker exec -it consul-server-1 /bin/sh

consul acl bootstrap

export CONSUL_HTTP_TOKEN=&amp;lt;SecretID&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;In the file variables.tf add your "SecretID".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;variable "consul_token" {
  default     = "&amp;lt;SecretID&amp;gt;"
  description = "Secret ID"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next step, configure Acl's for the services that will be part of Consul Server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply -target=module.consul_runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Access url &lt;a href="http://consul.redstack.local:8500" rel="noopener noreferrer"&gt;http://consul.redstack.local:8500&lt;/a&gt; in your browser and insert SecretID.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flogt4wyeul8h31pb8ahl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flogt4wyeul8h31pb8ahl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the ACL menu you can view the Acl's created with terraform.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmhj3un10o67mjdprxehl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fmhj3un10o67mjdprxehl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Access the container again and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it consul-server-1 /bin/sh

export CONSUL_HTTP_TOKEN=&amp;lt;SecretID&amp;gt;

consul acl set-agent-token default "&amp;lt;Agent Consul Token&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First part completed, in the next article we will continue to deploy the rest of the services :)&lt;/p&gt;

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