<?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>DEV Community: Lucas M. Ríos</title>
    <description>The latest articles on DEV Community by Lucas M. Ríos (@xlmriosx).</description>
    <link>https://dev.to/xlmriosx</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%2F991915%2Fa940ce05-2e9b-4e9e-a281-e9318db64af5.png</url>
      <title>DEV Community: Lucas M. Ríos</title>
      <link>https://dev.to/xlmriosx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xlmriosx"/>
    <language>en</language>
    <item>
      <title>How to configure multiple environments with Ansible Automation Platform?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Sun, 02 Apr 2023 20:28:48 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-to-configure-multiple-environments-with-ansible-automation-platform-55e5</link>
      <guid>https://dev.to/xlmriosx/how-to-configure-multiple-environments-with-ansible-automation-platform-55e5</guid>
      <description>&lt;h1&gt;
  
  
  🦾 Introduction to environment configuration with Ansible Automation Platform
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/projects/tree/main/"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;🚀 Ansible is a powerful configuration management tool that can be used for provisioning infrastructure.&lt;/p&gt;

&lt;p&gt;🛠️ Provisioning refers to the process of configuring and setting up remote systems or infrastructure.&lt;/p&gt;

&lt;p&gt;📝 Ansible uses Playbooks, which are written in YAML format, to define the desired state of the infrastructure.&lt;/p&gt;

&lt;p&gt;📦 Ansible provides many built-in modules for performing provisioning tasks, such as installing packages, configuring network settings, managing users and groups, and more.&lt;/p&gt;




&lt;h3&gt;
  
  
  Glosary
&lt;/h3&gt;

&lt;p&gt;AAP: Ansible Automation Platform&lt;/p&gt;




&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Supose you have an app and need deploy it in three or more enviornment with specific configuration.&lt;/p&gt;

&lt;p&gt;Imagine deploy manually all application included configuration is easy and manageble, but in a small organization will have a minimum of ten applications this is tedious but managable configurate in each server.&lt;/p&gt;

&lt;p&gt;Now think in twenty applications this is simply unimaginable manage fast and apply configuration correctly.&lt;/p&gt;

&lt;p&gt;In my last time, I have worked a lot with Ansible using AAP and solved many problems in deploying and updating applications. &lt;/p&gt;

&lt;p&gt;Other times we don't make mistakes just simply the server doesn't have infrastructure settings appropriately.&lt;/p&gt;




&lt;h3&gt;
  
  
  What we need to fix all of that?
&lt;/h3&gt;

&lt;p&gt;We will use a function called renderize.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I want belive you have this step. &lt;br&gt;
We need use good practices of development and understand holisticly all system. Included code, data bases, server, settings...&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a repo with app. I calling app to code. &lt;br&gt;
Supose this is called as "repo-app".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a repo with configuration values by each environment. &lt;br&gt;
Supose this is called as "repo-config".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a repo with ansible code configuration.&lt;br&gt;
Supose this is called as "repo-ansible".&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  What we need make in repo-app?
&lt;/h3&gt;

&lt;p&gt;In files where exists configuration specific of each environment like database of develop, qa and master; or values to configure Auth0.&lt;br&gt;
Files can has any format, i.e: json, yaml, xml, etc.&lt;/p&gt;

&lt;p&gt;We will write files where:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# appsetings.json
{
  "API": {
    "Endpoint": "**Endpoint-develop**"
  },
  "reCaptcha": {
    "SiteKey": "**SiteKey-develop**",
    "SecretKey": "**SecretKey-develop**",
    "Score": **Score-develop**,
  },  
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Insted set values set { { NAME_VARIABLE } }, key squares need are join:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# appsetings.json
{
  "API": {
    "Endpoint": "{ { Client.Endpoint } }"
  },
  "reCaptcha": {
    "SiteKey": "{ { Client.SiteKey } }",
    "SecretKey": "{ { Client.SecretKey } }",
    "Score": { { Client.Score } },
  },  
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What we need make in repo-config?
&lt;/h3&gt;

&lt;p&gt;WARNING: This repo is special, so stay focus. We don't make merge or promote between branchs. We work with each branch as independent.&lt;/p&gt;

&lt;p&gt;In my case I use a file in format yaml to set values of configurations.&lt;/p&gt;

&lt;p&gt;Here we set values and this values will appear in server where will be app and values where we configurate with { { NAME_VARIABLE } }:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
# appsetings.yaml
Client:
  Endpoint: Endpoint-develop
  SiteKey: SiteKey-develop
  SecretKey: SecretKey-develop
  Score: Score-develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In qa:&lt;br&gt;
Insted set values set { { NAME_VARIABLE } }:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
# appsetings.yaml
Client:
  Endpoint: Endpoint-qa
  SiteKey: SiteKey-qa
  SecretKey: SecretKey-qa
  Score: Score-qa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In master:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
# appsetings.yaml
Client:
  Endpoint: Endpoint-master
  SiteKey: SiteKey-master
  SecretKey: SecretKey-master
  Score: Score-master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you can put some secrets encrypted with vault and later this will be renderize with AAP credentials.&lt;/p&gt;

&lt;p&gt;And other file with origin and destination of files to renderize:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
# templates.yaml
templates:
  - origin: { { local_path } }/appsettings.json
    dest: { { dest_path } }/appsettings.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add many origin and dest for files to set values in your server.&lt;/p&gt;




&lt;h3&gt;
  
  
  What we need make in repo-ansible?
&lt;/h3&gt;

&lt;p&gt;Usually we will have a repo with only a branch that will be used.&lt;/p&gt;

&lt;p&gt;The tasks we need use to renderize app are:&lt;br&gt;
Note: Imagine we use group vars.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
# renderize.yaml
- name: Download app
  git:
    repo: "https://{ { repos.app.url } }"
    dest: "{ { repos.app.dir } }"
    version: "{ { repos.app.branch } }"
    force: no
  delegate_to: localhost
  run_once: true

- name: Download config
  git:
    repo: "https://{ { repos.config.url } }"
    dest: "{ { repos.config.dir } }"
    version: "{ { repos.config.branch } }"
    force: no
  delegate_to: localhost
  run_once: true

# TO WINDOWS
- name: Renderize templates in windows
  win_template:
    src: "{ { repos.app.dir } }/{ { item.origin } }"
    dest: "{ { item.dest } }"
  loop: "{ { templates } }"

# TO LINUX
- name: Renderize templates in linux
  template:
    src: "{ { repos.app.dir } }/{ { item.origin } }"
    dest: "{ { item.dest } }"
  loop: "{ { templates } }"

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>ansible</category>
    </item>
    <item>
      <title>Provisioning Infrastructure with Ansible</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Sun, 26 Mar 2023 23:00:19 +0000</pubDate>
      <link>https://dev.to/xlmriosx/provisioning-infrastructure-with-ansible-41i4</link>
      <guid>https://dev.to/xlmriosx/provisioning-infrastructure-with-ansible-41i4</guid>
      <description>&lt;h1&gt;
  
  
  🦾 Introduction to provision with Ansible
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/projects/tree/main/"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;🚀 Ansible is a powerful configuration management tool that can be used for provisioning infrastructure.&lt;/p&gt;

&lt;p&gt;🛠️ Provisioning refers to the process of configuring and setting up remote systems or infrastructure.&lt;/p&gt;

&lt;p&gt;📝 Ansible uses Playbooks, which are written in YAML format, to define the desired state of the infrastructure.&lt;/p&gt;

&lt;p&gt;📦 Ansible provides many built-in modules for performing provisioning tasks, such as installing packages, configuring network settings, managing users and groups, and more.&lt;/p&gt;

&lt;p&gt;💻 To provision infrastructure with Ansible, you'll need to:&lt;/p&gt;

&lt;p&gt;Install Ansible&lt;br&gt;
Define your infrastructure using Playbooks&lt;br&gt;
Create an inventory file&lt;br&gt;
Execute the playbook using the ansible-playbook command&lt;br&gt;
🖥️ Ansible can also be used for provisioning Windows systems, but this requires some additional setup and configuration, such as configuring the WinRM service on the target Windows system and specifying the WinRM connection details in the inventory file.&lt;/p&gt;

&lt;p&gt;Overall, provisioning with Ansible provides a way to automate the process of configuring and setting up infrastructure, reducing the risk of human error and increasing efficiency. 🤖&lt;/p&gt;


&lt;h3&gt;
  
  
  What is provisining in Ansible?
&lt;/h3&gt;

&lt;p&gt;In Ansible, provisioning refers to the process of configuring and setting up remote systems or infrastructure. Ansible is a configuration management tool that uses a declarative language to describe the desired state of the infrastructure. This means that instead of specifying individual tasks to be performed, you describe the desired end state of the system, and Ansible figures out how to get there.&lt;/p&gt;

&lt;p&gt;Provisioning in Ansible involves defining the configuration of the remote systems or infrastructure in a playbook, which is a YAML file that lists the tasks to be performed. These tasks can include installing packages, configuring network settings, setting up users and groups, and more. Ansible then connects to the remote systems over SSH and executes the tasks in the playbook.&lt;/p&gt;

&lt;p&gt;Ansible provides a number of built-in modules that can be used to perform provisioning tasks, such as the apt module for managing packages on Ubuntu systems, the yum module for managing packages on Red Hat-based systems, and the user module for managing users and groups.&lt;/p&gt;

&lt;p&gt;Overall, provisioning with Ansible provides a way to automate the process of configuring and setting up infrastructure, reducing the risk of human error and increasing efficiency.&lt;/p&gt;


&lt;h3&gt;
  
  
  How I can provision infrastructure with Ansible?
&lt;/h3&gt;

&lt;p&gt;To provision infrastructure with Ansible, you'll need to follow these basic steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install Ansible on your local machine or on a server that will be used to run Ansible commands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define the desired state of your infrastructure using Ansible Playbooks, which are written in YAML format. Playbooks contain a list of tasks that will be executed on the remote systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create an inventory file that lists the hostnames or IP addresses of the systems you want to provision, as well as any necessary connection details such as SSH keys or usernames/passwords.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute the playbook using the ansible-playbook command, specifying the inventory file and playbook file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's an example of what a simple Ansible playbook might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
- name: Provision a web server
  hosts: webservers
  become: true

  tasks:
  - name: Install Apache web server
    apt:
      name: apache2
      state: present
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This playbook will provision a web server by installing the Apache web server package using the apt module. The hosts parameter specifies the target systems, and become: true tells Ansible to use sudo to execute the tasks as a privileged user.&lt;/p&gt;

&lt;p&gt;To execute this playbook, you would 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;ansible-playbook -i inv.yaml playbook.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where inv.yaml is the name of your inventory file, and playbook.yml is the name of your playbook file.&lt;/p&gt;

&lt;p&gt;Ansible provides many built-in modules that can be used to perform various provisioning tasks, such as installing packages, configuring network settings, managing users and groups, and more. You can also create your own custom modules if needed.&lt;/p&gt;

&lt;p&gt;Look we talk to provision in systems with base Unix.&lt;/p&gt;




&lt;h3&gt;
  
  
  And in Windows?
&lt;/h3&gt;

&lt;p&gt;Ansible can also be used for provisioning Windows systems. However, provisioning Windows systems with Ansible requires some additional setup and configuration compared to provisioning Linux systems. Here are the basic steps to provision a Windows system with Ansible:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install Ansible on a Linux system or a Windows system with the Windows Subsystem for Linux (WSL) enabled. Ansible cannot be installed directly on a Windows system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure the WinRM service on the target Windows system to allow remote management. WinRM is Microsoft's implementation of the WS-Management protocol, which allows remote management of Windows systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create an inventory file that lists the target Windows system and specifies the connection details, including the WinRM username and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write a playbook that contains tasks to configure the Windows system as desired. Ansible provides several built-in modules for configuring Windows systems, including modules for managing users, groups, and Windows features.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execute the playbook using the ansible-playbook command, specifying the inventory file and playbook file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's an example of what a simple Ansible playbook for Windows might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
- name: Provision a Windows server
  hosts: windows
  gather_facts: no
  become: yes

  tasks:
  - name: Install IIS web server
    win_feature:
      name: Web-Server
      state: present
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This playbook installs the IIS web server feature on a Windows system using the win_feature module. The hosts parameter specifies the target Windows system, and become: yes tells Ansible to execute the tasks as an administrator.&lt;/p&gt;

&lt;p&gt;To execute this playbook, you would 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;ansible-playbook -i inv.yaml playbook.yml --extra-vars "ansible_user=&amp;lt;winrm_username&amp;gt; ansible_password=&amp;lt;winrm_password&amp;gt; ansible_connection=winrm ansible_winrm_transport=basic ansible_winrm_server_cert_validation=ignore"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where inv.yaml is the name of your inventory file, playbook.yml is the name of your playbook file, and winrm_username and winrm_password are the username and password for the WinRM connection. The --extra-vars parameter is used to pass the WinRM connection details to Ansible. The ansible_winrm_server_cert_validation=ignore option is used to disable certificate validation, which is often necessary in testing or development environments.&lt;/p&gt;

&lt;p&gt;Overall, provisioning Windows systems with Ansible requires some additional setup and configuration compared to provisioning Linux systems, but Ansible provides many built-in modules that can be used to configure and manage Windows systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>ansible</category>
    </item>
    <item>
      <title>Getting Started with Ansible: An Introduction to Automation, Configuration Management, and Orchestration</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Sat, 18 Mar 2023 21:40:44 +0000</pubDate>
      <link>https://dev.to/xlmriosx/getting-started-with-ansible-an-introduction-to-automation-configuration-management-and-orchestration-1h95</link>
      <guid>https://dev.to/xlmriosx/getting-started-with-ansible-an-introduction-to-automation-configuration-management-and-orchestration-1h95</guid>
      <description>&lt;h1&gt;
  
  
  🔐 Introduction to Ansible
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/projects/tree/main/"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;📜 Nothing to resume,it's simple.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;🤖 Ansible is an open-source automation tool that simplifies complex tasks, speeds up workflows, and increases productivity. It allows users to automate configuration management, application deployment, and task automation.&lt;/p&gt;

&lt;p&gt;🔑 Ansible is agentless, which means it does not require any software or agent to be installed on the remote machines that it manages. Instead, it uses SSH or WinRM to connect to remote hosts.&lt;/p&gt;

&lt;p&gt;📝 Ansible uses a simple and human-readable syntax called YAML (Yet Another Markup Language), which makes it easy for users to create and manage their automation scripts. Ansible playbooks are written in YAML and are a set of instructions that tell Ansible what to do.&lt;/p&gt;




&lt;h3&gt;
  
  
  Uses
&lt;/h3&gt;

&lt;p&gt;💻 Ansible supports a wide range of platforms, including Linux, Unix, macOS, and Windows. It also integrates with a variety of cloud providers such as AWS, Azure, and Google Cloud Platform.&lt;/p&gt;

&lt;p&gt;♻️ Ansible's idempotent nature allows it to be run multiple times without changing the end result. This makes it easy to test and re-run automation scripts without worrying about undesired changes or side effects.&lt;/p&gt;

&lt;p&gt;🛠️ Ansible is highly extensible and can be integrated with other tools and services. For example, it can be integrated with Git, Jenkins, and many other DevOps tools to create a powerful and streamlined automation pipeline.&lt;/p&gt;




&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;Here are some examples of what Ansible can do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automate the installation and configuration of software packages on multiple servers&lt;/li&gt;
&lt;li&gt;Deploy web applications and services to multiple servers simultaneously&lt;/li&gt;
&lt;li&gt;Manage network devices such as switches and routers
Provision virtual machines in a cloud environment&lt;/li&gt;
&lt;li&gt;Configure and manage container orchestration platforms like Kubernetes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, Ansible is a powerful and flexible automation tool that can help organizations automate their IT workflows and increase their efficiency. Whether you're a developer, system administrator, or IT professional, Ansible can help you streamline your automation processes and achieve your automation goals.&lt;/p&gt;




&lt;h3&gt;
  
  
  Practical case
&lt;/h3&gt;

&lt;p&gt;Let's say you have a web application that you want to deploy to multiple servers simultaneously. You want to automate the process of deploying the application to the servers and make sure that the servers are configured correctly before the deployment. You also want to ensure that the application is deployed consistently across all servers, even if you need to re-run the deployment process.&lt;/p&gt;

&lt;p&gt;To accomplish this, you can use Ansible to write a playbook that automates the deployment and configuration process. Here's an example of what the playbook might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
- name: Deploy web application
  hosts: webservers
  become: yes

  vars:
    app_name: myapp
    app_version: 1.0.0
    app_port: 8080

  tasks:
    - name: Install dependencies
      apt:
        name: ["git", "python3-pip", "nginx"]
        state: present

    - name: Clone repository
      git:
        repo: https://github.com/myusername/myapp.git
        dest: /opt/{{ app_name }}-{{ app_version }}

    - name: Install Python dependencies
      pip:
        requirements: /opt/{{ app_name }}-{{ app_version }}/requirements.txt

    - name: Configure Nginx
      template:
        src: nginx.conf.j2
        dest: /etc/nginx/sites-available/{{ app_name }}
      notify:
        - Reload Nginx

    - name: Enable site
      file:
        src: /etc/nginx/sites-available/{{ app_name }}
        dest: /etc/nginx/sites-enabled/{{ app_name }}
        state: link
      notify:
        - Reload Nginx

    - name: Start application service
      systemd:
        name: {{ app_name }}
        state: started
        enabled: yes
        daemon_reload: yes

  handlers:
    - name: Reload Nginx
      systemd:
        name: nginx
        state: reloaded

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

&lt;/div&gt;



&lt;p&gt;In this example, the playbook specifies that it will be run on a group of hosts called "webservers". It then defines a set of tasks that will be executed on each of these hosts.&lt;/p&gt;

&lt;p&gt;The first task installs the necessary dependencies on the hosts using the apt module. The next task clones the application's Git repository to the hosts using the git module. The third task installs the Python dependencies of the application using the pip module.&lt;/p&gt;

&lt;p&gt;The fourth task configures Nginx by generating a template file based on a Jinja2 template and copying it to the appropriate location using the template module. It then notifies the Reload Nginx handler, which is defined later in the playbook.&lt;/p&gt;

&lt;p&gt;The fifth task enables the Nginx site by creating a symbolic link to the site's configuration file using the file module. It also notifies the Reload Nginx handler.&lt;/p&gt;

&lt;p&gt;The sixth and final task starts the application service using the systemd module. It also ensures that the service is enabled to start automatically on boot and notifies daemon_reload to reload the systemd configuration.&lt;/p&gt;

&lt;p&gt;The playbook also defines a handler called Reload Nginx, which reloads the Nginx configuration using the systemd module.&lt;/p&gt;

&lt;p&gt;By running this playbook with Ansible, you can automate the deployment and configuration of your web application across multiple servers with ease.&lt;/p&gt;




&lt;h3&gt;
  
  
  Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>devops</category>
      <category>ansible</category>
    </item>
    <item>
      <title>A Beginner's Guide to Vault: Understanding Secrets, Credentials, and Secure Data Management</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Sat, 11 Mar 2023 02:29:43 +0000</pubDate>
      <link>https://dev.to/xlmriosx/a-beginners-guide-to-vault-understanding-secrets-credentials-and-secure-data-management-4a77</link>
      <guid>https://dev.to/xlmriosx/a-beginners-guide-to-vault-understanding-secrets-credentials-and-secure-data-management-4a77</guid>
      <description>&lt;h1&gt;
  
  
  🔐 Introduction to Credential and Secrets
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/projects/tree/main/"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;📜 Vault: Definition and explanation of Vault as a tool for securely storing and managing sensitive data.&lt;/li&gt;
&lt;li&gt;🤫 Secret: Explanation of what secrets are and their importance in security.&lt;/li&gt;
&lt;li&gt;🔑 Credential: Explanation of credentials as a type of secret used for authentication and authorization.&lt;/li&gt;
&lt;li&gt;🏆 Importance: Discussion of the importance of secrets and credentials in security.&lt;/li&gt;
&lt;li&gt;🚀 Use Cases: Examples of use cases for Vault, including managing application secrets, secure access management, configuration management, dynamic secrets, and encryption/tokenization.&lt;/li&gt;
&lt;li&gt;💻 Examples: Additional examples of how Vault can be used in practical applications.&lt;/li&gt;
&lt;li&gt;📄 Command Line: Explanation of how to create a Vault from a file or string in command line.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  What is Vault? 📜
&lt;/h3&gt;

&lt;p&gt;In Ansible, a "vault" is a feature that allows you to encrypt sensitive data such as passwords, API keys, and other credentials used in your playbooks and roles.&lt;/p&gt;

&lt;p&gt;When you create a vault, you use a password to encrypt the data, and only someone who has the password can access the data. This helps ensure that sensitive information is not visible to unauthorized users who may have access to your Ansible code.&lt;/p&gt;

&lt;p&gt;To create a vault in Ansible, you use the ansible-vault command line tool. You can create a new encrypted file or edit an existing one with the edit subcommand, and you can also encrypt and decrypt files with the encrypt and decrypt subcommands.&lt;/p&gt;

&lt;p&gt;Once you have created a vault, you can use the include_vars module or the vars_prompt module to prompt the user for the password and then use the vault lookup plugin to access the encrypted variables in your playbook or role. The vault lookup plugin will automatically decrypt the data using the password provided.&lt;/p&gt;

&lt;p&gt;Using a vault in Ansible is a best practice for handling sensitive data and can help you secure your automation workflows.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is a secret? 🤫
&lt;/h3&gt;

&lt;p&gt;In the context of computing and security, a "secret" refers to any piece of sensitive or confidential information that should be kept private and protected from unauthorized access. Secrets can take many forms, such as passwords, encryption keys, API keys, access tokens, private certificates, and other types of credentials that are used to authenticate users or systems and grant access to protected resources.&lt;/p&gt;

&lt;p&gt;Keeping secrets secure is critical for protecting sensitive data and preventing unauthorized access and data breaches. This is why secrets are often stored in secure locations, such as encrypted databases, hardware security modules, or cloud-based key management services, and are accessed using strict authentication and authorization controls.&lt;/p&gt;

&lt;p&gt;Many software tools and frameworks provide built-in mechanisms for storing and managing secrets securely, such as Ansible Vault, HashiCorp Vault, Kubernetes Secrets, and AWS Secrets Manager, to name a few. These tools allow you to store, manage, and distribute secrets across different systems and environments securely, using encryption, access controls, and other security features to ensure that sensitive information is protected from unauthorized access.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is a credential? 🔑
&lt;/h3&gt;

&lt;p&gt;In the context of computing and security, a "credential" refers to any piece of information that is used to authenticate and authorize a user, system, or application to access a resource or perform an action. Credentials can take many forms, including usernames, passwords, access keys, API tokens, certificates, and other types of secrets.&lt;/p&gt;

&lt;p&gt;Credentials are used to establish trust between different systems and to ensure that only authorized entities can access protected resources. For example, when you log in to a website, you typically provide a username and password as credentials, which are verified by the website's authentication system to determine if you are authorized to access your account. Similarly, when you use an API to access a cloud service, you may need to provide an access key and secret as credentials to authenticate your request and authorize access to the service.&lt;/p&gt;

&lt;p&gt;Credentials are a critical aspect of security in computing, and their management is essential to ensure the confidentiality, integrity, and availability of sensitive data and systems. Credential management involves storing credentials securely, using encryption, access controls, and other security mechanisms to protect them from unauthorized access, and rotating them periodically to minimize the risk of compromise. Many tools and frameworks provide built-in support for credential management, such as password managers, key management services, and identity and access management (IAM) systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  What is difference between a credential and secret? 🏆
&lt;/h3&gt;

&lt;p&gt;While the terms "credential" and "secret" are often used interchangeably, there is a subtle difference between them.&lt;/p&gt;

&lt;p&gt;A "credential" refers to any piece of information that is used to authenticate and authorize a user, system, or application to access a resource or perform an action. Credentials can take many forms, including usernames, passwords, access keys, API tokens, certificates, and other types of secrets.&lt;/p&gt;

&lt;p&gt;On the other hand, a "secret" specifically refers to any piece of sensitive or confidential information that should be kept private and protected from unauthorized access. Secrets can take many forms, such as passwords, encryption keys, API keys, access tokens, private certificates, and other types of credentials used to authenticate users or systems and grant access to protected resources.&lt;/p&gt;

&lt;p&gt;In essence, all secrets are credentials, but not all credentials are secrets. Credentials include both public and private information that is used for authentication and authorization, whereas secrets specifically refer to private information that must be kept confidential to prevent unauthorized access.&lt;/p&gt;

&lt;p&gt;For example, a username is a credential but not necessarily a secret, since it may be publicly known or easily guessed. A password, on the other hand, is both a credential and a secret, since it must be kept private to ensure secure authentication.&lt;/p&gt;




&lt;h3&gt;
  
  
  Which is more important? 🏅
&lt;/h3&gt;

&lt;p&gt;Both credentials and secrets are important in the context of computing and security, and their management is essential to ensure the confidentiality, integrity, and availability of sensitive data and systems.&lt;/p&gt;

&lt;p&gt;Credentials are critical because they are used to establish trust between different systems and to ensure that only authorized entities can access protected resources. Strong credentials, such as complex passwords and unique access keys, can help prevent unauthorized access and reduce the risk of data breaches and other security incidents.&lt;/p&gt;

&lt;p&gt;Secrets are also critical because they are used to protect sensitive information and prevent it from falling into the wrong hands. Effective secret management involves storing secrets securely, using encryption, access controls, and other security mechanisms to protect them from unauthorized access, and rotating them periodically to minimize the risk of compromise.&lt;/p&gt;

&lt;p&gt;In summary, both credentials and secrets are important, and their management is essential to ensure the security of computing systems and data. Organizations must adopt best practices for managing credentials and secrets, including strong authentication and authorization mechanisms, secure storage, and regular rotation to minimize the risk of compromise.&lt;/p&gt;




&lt;h3&gt;
  
  
  Where I can use vault? 💻
&lt;/h3&gt;

&lt;p&gt;A vault is a secure storage location used to store and manage sensitive data such as credentials, secrets, and other types of confidential information. Vault tools can be used in a variety of contexts where secure storage and management of secrets are required, including:&lt;/p&gt;

&lt;p&gt;Configuration management: Vault can be used with tools like Ansible and Terraform to store sensitive configuration data such as API keys, passwords, and access tokens.&lt;/p&gt;

&lt;p&gt;Application development: Vault can be used to store sensitive data such as encryption keys, certificates, and database credentials required by applications during runtime.&lt;/p&gt;

&lt;p&gt;Cloud computing: Vault can be used with cloud service providers such as AWS, Google Cloud Platform, and Microsoft Azure to store secrets required by cloud applications, services, and APIs.&lt;/p&gt;

&lt;p&gt;DevOps: Vault can be used to manage secrets required by DevOps tools like Jenkins, GitLab, and CircleCI.&lt;/p&gt;

&lt;p&gt;Cybersecurity: Vault can be used to securely store and manage sensitive data required by cybersecurity tools such as firewalls, intrusion detection systems, and threat intelligence platforms.&lt;/p&gt;

&lt;p&gt;In summary, Vault can be used in a variety of contexts where secure storage and management of secrets are required, including configuration management, application development, cloud computing, DevOps, and cybersecurity.&lt;/p&gt;




&lt;h3&gt;
  
  
  Use cases 🚀
&lt;/h3&gt;

&lt;p&gt;Vault is a tool for securely storing and managing sensitive data such as credentials, secrets, and other types of confidential information. Some common use cases of Vault include:&lt;/p&gt;

&lt;p&gt;Managing application secrets: Applications often require sensitive information such as API keys, database credentials, and encryption keys to function. Vault can be used to store and manage these secrets, providing a centralized and secure way to manage application secrets.&lt;/p&gt;

&lt;p&gt;Secure access management: Vault can be used to manage access to resources such as SSH keys, TLS certificates, and cloud service access keys. By storing these credentials in Vault and using Vault's access controls and policies, administrators can manage and audit access to these resources more easily.&lt;/p&gt;

&lt;p&gt;Configuration management: Vault can be used with tools such as Ansible and Terraform to store sensitive configuration data, such as secrets required by infrastructure-as-code scripts. This makes it easier to manage and maintain these scripts while keeping sensitive data secure.&lt;/p&gt;

&lt;p&gt;Dynamic secrets: Vault can generate dynamic secrets that are short-lived and tied to specific applications or services. This can help reduce the risk of stolen or leaked secrets, as these dynamic secrets expire after a specified period of time.&lt;/p&gt;

&lt;p&gt;Encryption and tokenization: Vault can be used to encrypt data at rest and in transit, as well as to tokenize sensitive data. This can help protect sensitive data and make it easier to manage and store securely.&lt;/p&gt;

&lt;p&gt;In summary, Vault can be used in a wide range of use cases that involve managing sensitive data securely, including managing application secrets, access management, configuration management, dynamic secrets, and encryption/tokenization.&lt;/p&gt;




&lt;h3&gt;
  
  
  How can create a vault from a file and by a string in command line? 📄
&lt;/h3&gt;

&lt;p&gt;To create a vault in command line, you can use the ansible-vault command.&lt;/p&gt;

&lt;p&gt;To create a vault from a file, you can use the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ansible-vault create &amp;lt;filename&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create a new encrypted vault file with the specified filename. You will be prompted to enter a password that will be used to encrypt and decrypt the file.&lt;/p&gt;

&lt;p&gt;To create a vault from a string, you can use the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ansible-vault encrypt_string &amp;lt;string&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will encrypt the specified string and output it in a format that can be included in a playbook or inventory file. You will be prompted to enter a password that will be used to encrypt and decrypt the string.&lt;/p&gt;

&lt;p&gt;For example, to encrypt the string "mysecret" and output it to the console, you can run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ansible-vault encrypt_string mysecret&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will output the encrypted string in a format like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;!vault |
          $ANSIBLE_VAULT;1.1;AES256
          66326266373333633033646434333231353062313661646637626637346464353534653937623566
          3833336333323064373632653664623131653966623361320a306132383933343734656433313439
          63386334333737363862393461396334613836613132303265333865303265373465343561643130
          6430316166633437360a623366613632663238666565353832306233393064313964633062393238
          3235

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

&lt;/div&gt;



&lt;p&gt;This encrypted string can then be included in a playbook or inventory file using the !vault tag, and decrypted using the same password used to encrypt it.&lt;/p&gt;




&lt;h3&gt;
  
  
  Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>security</category>
      <category>devops</category>
      <category>sre</category>
      <category>ansible</category>
    </item>
    <item>
      <title>Introduction with examples to Emu8086</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Fri, 03 Mar 2023 23:29:05 +0000</pubDate>
      <link>https://dev.to/xlmriosx/introduction-with-examples-to-emu8086-54lh</link>
      <guid>https://dev.to/xlmriosx/introduction-with-examples-to-emu8086-54lh</guid>
      <description>&lt;h1&gt;
  
  
  ☢️ Introduction with examples to Emu8086
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/projects/tree/main/scripts/emu8086"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;Here we will have a brief introduction with many examples of scripts to Emu8086. &lt;/p&gt;

&lt;p&gt;[WARNING ⚠️] This is a low level of programming, so I recommend you be so inspired. 😁&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Emu8086?
&lt;/h3&gt;

&lt;p&gt;EMU8086 is an emulator that allows you to run and test programs written in assembly language on a Windows computer. It is a software tool that can emulate the hardware and software of a microprocessor, specifically the Intel 8086 microprocessor, which was used in the original IBM PC.&lt;/p&gt;

&lt;p&gt;The emulator can be used to write, debug and test programs for the 8086 architecture. It provides an environment that is similar to the actual hardware on which the program would run, allowing programmers to develop code that is optimized for the specific hardware platform.&lt;/p&gt;

&lt;p&gt;EMU8086 is popular among students and hobbyists who are interested in learning assembly language programming, as well as in reverse engineering and debugging software. It also includes a built-in assembler, which allows users to write and assemble programs directly within the emulator.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is assembly?
&lt;/h3&gt;

&lt;p&gt;Assembly language is a low-level programming language that is used to write programs that are executed by a computer's microprocessor. It is a symbolic representation of the machine language code that can be executed by the CPU (Central Processing Unit) of a computer.&lt;/p&gt;

&lt;p&gt;Assembly language programs are typically used to control hardware directly, as they can be used to manipulate the individual bits and bytes of a computer's memory and CPU registers. Unlike high-level programming languages such as Java or Python, which are easier to read and write but require an interpreter or compiler to run, assembly language programs are written using mnemonic codes that correspond to specific CPU instructions.&lt;/p&gt;

&lt;p&gt;Writing programs in assembly language can be challenging, as programmers must have a good understanding of the underlying hardware and be able to write code that is both efficient and concise. However, assembly language can be useful in situations where high performance or low-level control of hardware is required, such as in embedded systems, operating systems, or device drivers.&lt;/p&gt;




&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;Okay, now we will see some examples. If you want prove this programs you can download &lt;a href="https://down01.wxsrv.com/descargando/024/2412/emu8086/057/emu8086.exe?val=2412&amp;amp;loc=descargar"&gt;Emu8086&lt;/a&gt; remember this is only for Windows systems.&lt;/p&gt;

&lt;h4&gt;
  
  
  1️⃣Simple example of move data
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;; Perform a program that exchanges the contents
; of two decimal values defined in data1 and data2

.data
data1 db 11
data2 db 22

.code

EXCHANGE:
    MOV AL, data1
    MOV AH, data2
    MOV data1, AH
    MOV data2, AL

END:
    HLT

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  2️⃣Simple(no really) example of multiply two numbers interactively
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;; Make the multiplication of two numbers entered by keyboard,
; to store the result in the result variable
; print the result on the screen

INCLUDE 'EMU8086.INC'

org 100h

.data

Result db ?

.code
    INIT_VAR:
        MOV Result, 0
    GET_VALUES:
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "SET A MULTIPLIER: ",0
        CALL SCAN_NUM
        MOV BL, CL 
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "SET A MULTIPLICATOR: ",0   
        CALL SCAN_NUM
        MOV AL, CL

    MULTIPLY:
        ADD Result, BL
        DEC AL        
        JZ SHW_RESULT
        JMP MULTIPLY 

    SHW_RESULT: 
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "RESULT IS: ", 0       
        MOV AL, Result
        CALL PRINT_NUM

END:
    DEFINE_PTHIS
    DEFINE_SCAN_NUM
    DEFINE_PRINT_NUM 
    DEFINE_PRINT_NUM_UNS  
    DEFINE_CLEAR_SCREEN
    HLT

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  3️⃣Super simple(defintively no really) example of a calculator
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;; Perform a program that works as a calculator of 2 whole numbers,
; and allow the 4 basic operations. The keyboard must be entered by the
; numbers and the operation to be performed. Then print the result obtained.
INCLUDE "EMU8086.INC"

ORG 0x100h

.DATA
OPTION DB 0
VALUE1 DB 0
VALUE2 DB 0
RESULT DB 0

.CODE
START:
    GET_OPERATION:
        CALL PTHIS
        DB "SET A OPTION. 1-SUM, 2-SUBSTRACTION, 3-MULT, 4-DIVISION: ",0
        MOV CX, 0
        CALL SCAN_NUM
        MOV OPTION, CL

    GET_NUMS:
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "SET VALUE 1: ",0
        MOV CX, 0
        CALL SCAN_NUM
        MOV VALUE1, CL

        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "SET VALUE 2: ",0 
        MOV CX, 0
        CALL SCAN_NUM
        MOV VALUE2, CL        

    SELECT_OPT:
        MOV AL, OPTION
        SUB AX, 1
        JZ SUM

        MOV AL, OPTION
        SUB AX, 2
        JZ RESTA

        MOV AL, OPTION
        SUB AX, 3
        JZ MULT

        MOV AL, OPTION
        SUB AX, 4
        JZ DIVISION

        JMP NO_VALID

    NO_VALID:
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "OPTION NO VALID",0
        JMP END

    SUM:
        MOV AX, 0
        MOV AL, VALUE1
        ADD AL, VALUE2
        MOV RESULT, AL
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "RESULT DE SUM: ",0
        MOV AX, 0
        MOV AL, RESULT
        CALL PRINT_NUM
        JMP END         

    RESTA:
        MOV AX, 0
        MOV AL, VALUE1
        SUB AL, VALUE2
        MOV RESULT, AL
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "RESULT DE RESTA: ",0 
        MOV AX, 0
        MOV AL, RESULT
        CALL PRINT_NUM
        JMP END

    MULT:
        MOV AX, 0
        MOV BX, 0
        MOV AL, VALUE1
        MOV BL, VALUE2
        IMUL BL
        MOV RESULT, AL
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "RESULT DE MULT: ",0 
        MOV AX, 0
        MOV AL, RESULT
        CALL PRINT_NUM
        JMP END

    DIVISION:
        MOV AX, 0
        MOV AL, VALUE1
        MOV BL, VALUE2
        IDIV BL
        MOV RESULT, AL
        CALL CLEAR_SCREEN
        CALL PTHIS
        DB "RESULT DE DIVISION: ",0
        MOV AX, 0
        MOV AL, RESULT
        CALL PRINT_NUM
        JMP END

END:
    HLT
    DEENDE_PTHIS
    DEENDE_PRINT_NUM
    DEENDE_PRINT_NUM_UNS
    DEENDE_SCAN_NUM  
    DEENDE_CLEAR_SCREEN

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

&lt;/div&gt;



&lt;p&gt;You can get more exercises in &lt;a href="https://github.com/xlmriosx/projects/tree/main/scripts/emu8086#index"&gt;repo&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>architecture</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How upload data in format JSON to Datastore from GCP?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Sat, 25 Feb 2023 00:39:59 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-upload-data-in-format-json-to-datastore-from-gcp-20no</link>
      <guid>https://dev.to/xlmriosx/how-upload-data-in-format-json-to-datastore-from-gcp-20no</guid>
      <description>&lt;h1&gt;
  
  
  ⛵ Simple way to upload data in format JSON to Datastore from GCP.
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/cloud-projects/"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;All this blog is using shell.&lt;/p&gt;

&lt;p&gt;We will upload data to Datastore we can made this with Cloud SDK or directly from shell in GCP.&lt;/p&gt;

&lt;p&gt;We will create a script in json_to_datastore.py to upload data from restaurants.json to Datastore.&lt;/p&gt;

&lt;p&gt;If you want test this script, you can get example data in my repo that is above.&lt;/p&gt;

&lt;p&gt;For more information and potential of this, click &lt;a href="https://cloud.google.com/datastore"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  1st - Create a program python ✍️
&lt;/h3&gt;

&lt;p&gt;I use 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;touch json_to_datastore.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2nd - Write code to do transforms 🧵
&lt;/h3&gt;

&lt;p&gt;Open IDE(I use vi) and put the following script&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Only import libraries
from google.cloud import datastore
import sys
import json
import os

def to_unicode(string):
    return unicode(string, "utf-8")

def get_values_json(jsondata):
    # Getting values of object root
    restaurant_id = jsondata.get("restaurant_id")
    name = jsondata.get("name")
    cuisine = jsondata.get("cuisine")
    borough = jsondata.get("borough")
    address = jsondata.get("address", {})
    # Getting values of object address
    zipcode = address.get("zipcode", '')
    street = address.get("street", '')
    building = address.get("building", '')
    coord = address.get("coord", [0, 0] )
    longitude = coord[0]
    latitude = coord[1]
    return restaurant_id, name, cuisine,borough, zipcode, street, building, longitude, latitude

def set_values_entity(restaurants, restaurant_id, name, cuisine,borough, zipcode, street, building, longitude, latitude):
    # Assign encoded values to key
    restaurants['id'] = to_unicode(restaurant_id)
    restaurants['name'] = to_unicode(name)
    restaurants['cuisine'] = to_unicode(cuisine)
    restaurants['borough'] = to_unicode(borough)
    restaurants['zipcode'] = to_unicode(zipcode)
    restaurants['street'] = to_unicode(street)
    restaurants['building'] = to_unicode(building)
    restaurants['longitude'] = longitude
    restaurants['latitude'] = latitude
    return restaurants

def convert():
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    readFile = os.path.join(BASE_DIR, "restaurants.json")
    # Instantiates a client
    datastore_client = datastore.Client()
    # The kind for the new entity
    kind = 'restaurants'
    print ('\n' + 'Convert to Datastore - Please Wait' + '\n')

    # Set lines where will be row data
    lines = []
    # Open file restaurants.json
    with open(readFile, "r") as f:
        lines = f.readlines()

    # By each line of file we transform data and put it in entity in Datastore
    for line in lines:
        jsondata = json.loads(line)
        # Get values from json
        restaurant_id, name, cuisine,borough, zipcode, street, building, longitude, latitude = get_values_json(jsondata)
        # The Cloud Datastore key for the new entity
        rest_key = datastore_client.key(kind)
        # Prepares the new entity
        restaurants = datastore.Entity(key=rest_key)
        # Set values to entity
        restaurants = set_values_entity(restaurants, restaurant_id, name, cuisine,borough, zipcode, street, building, longitude, latitude)
        # Saves the entity
        datastore_client.put(restaurants)

    print ('\n' + 'Saved Rows to csv' + '\n')

if __name__ == '__main__':
    convert()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3rd - Run script 🙈
&lt;/h3&gt;

&lt;p&gt;We need restaurants.json is in same path of script.&lt;/p&gt;

&lt;p&gt;We run script with 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;python3 json_to_datastore.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;UALAAAAA! 🎩🪄&lt;br&gt;
You now have data in your instance of Datastore...&lt;/p&gt;




&lt;h3&gt;
  
  
  4th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>cloud</category>
      <category>tutorial</category>
      <category>python</category>
      <category>datascience</category>
    </item>
    <item>
      <title>How create cluster in Dataproc and install Jupyter?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Thu, 16 Feb 2023 20:07:16 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-create-cluster-in-dataproc-and-install-jupyter-8i4</link>
      <guid>https://dev.to/xlmriosx/how-create-cluster-in-dataproc-and-install-jupyter-8i4</guid>
      <description>&lt;h1&gt;
  
  
  💠 Simple way to start a cluster in Dataproc from GCP.
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/cloud-projects/" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;All this blog is using shell.&lt;/p&gt;

&lt;p&gt;We will start a cluster in Dataproc where we need first have SDK's Google and have instanced a bucket in Cloud Storage.&lt;/p&gt;

&lt;p&gt;For more information and potential of this, click &lt;a href="https://cloud.google.com/dataproc" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Pre-Conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need have installed SDK. You can do that following next &lt;a href="https://dev.to/xlmriosx/how-install-cloud-sdk-docker-image-in-gcp-4mep"&gt;steps&lt;/a&gt;
Note: I set alias to use SDK like msdk.&lt;/li&gt;
&lt;li&gt;You need have instanced a bucket. You can do that following next &lt;a href="https://dev.to/xlmriosx/how-install-cloud-sdk-docker-image-in-gcp-4mep"&gt;steps&lt;/a&gt;
Note: I set a bucket called xlmriosx_bucket.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  1st - Set a name to cluster ✍️
&lt;/h3&gt;

&lt;p&gt;We assign to a variable the name that will have cluster.&lt;/p&gt;

&lt;p&gt;I use 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;CLUSTER_NAME="xlmriosx_cluster"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2nd - Create bucket 💠
&lt;/h3&gt;

&lt;p&gt;Using SDK installed with alias like msdk I use following command to create a cluster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With alias:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msdk gcloud beta dataproc clusters create $CLUSTER_NAME \
    --optional-components=ANACONDA,JUPYTER \
    --image-version=$IMAGE_VERSION \
    --enable-component-gateway \
    --region=$REGION \
    --num-workers=$NUM_WORKERS \
    --master-machine-type=$MASTER_MACHINE_TYPE \
    --worker-machine-type=$WORKER_MACHINE_TYPE \
    --bucket=$BUCKET_NAME \
    --tags=$TAGS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;br&gt;
$CLUSTER_NAME -&amp;gt; Is name that will have your cluster. In this case xlmriosx_cluster.&lt;/p&gt;

&lt;p&gt;$IMAGE_VERSION -&amp;gt; Is version of image that will we use. Ex.: 1.3&lt;/p&gt;

&lt;p&gt;$REGION -&amp;gt; Region where you want stay your storage bucket. Ex.: us-central1 &lt;/p&gt;

&lt;p&gt;$NUM_WORKERS -&amp;gt; Is amount of workers or nodes that will process data. Ex.: 2&lt;/p&gt;

&lt;p&gt;$MASTER_MACHINE_TYPE -&amp;gt; Is type of machine that will use our master machine. Ex.: n1-standard-1&lt;/p&gt;

&lt;p&gt;$WORKER_MACHINE_TYPE -&amp;gt; Is type of machine that will use our workers machine. Ex.: n1-standard-1&lt;/p&gt;

&lt;p&gt;$BUCKET_NAME -&amp;gt; Is name of our cluster where will use like Source and Destination. Ex.: xlmriosx_bucket&lt;/p&gt;

&lt;p&gt;$TAGS -&amp;gt; Is a tag to know about what is the process that make cluster. Ex.: datascience&lt;/p&gt;


&lt;h3&gt;
  
  
  3rd - Verify that your bucket was created ✅
&lt;/h3&gt;

&lt;p&gt;We will list clusters to verify that was created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcloud beta dataproc clusters list --region=$REGION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
| NAME | WORKER_COUNT | PREEMPTIBLE_WORKER_COUNT |  STATUS |  ZONE |  SCHEDULED_DELETE | &lt;br&gt;
| --- | --- | --- | --- | --- | --- |&lt;br&gt;
| xlmriosx_cluster | 3 | - | - | RUNNING | us-central1-c |&lt;/p&gt;




&lt;h3&gt;
  
  
  4th - Open the Jupyter notebook in your local browser 🕸
&lt;/h3&gt;

&lt;p&gt;See &lt;a href="https://cloud.google.com/dataproc/docs/concepts/accessing/dataproc-gateways#viewing_and_accessing_component_gateway_urls" rel="noopener noreferrer"&gt;Viewing and Accessing Component Gateway URLs&lt;/a&gt; to click Component Gateway links on the Cloud Console to open the Jupyter notebook and JupyterLab UIs running on the cluster's master node in your local browser.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegcsgammkiuaz61zzmk3.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fegcsgammkiuaz61zzmk3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4th - Open the Jupyter notebook in your local browser 🕸
&lt;/h3&gt;







&lt;h3&gt;
  
  
  5th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>cloud</category>
      <category>datascience</category>
      <category>tutorial</category>
      <category>database</category>
    </item>
    <item>
      <title>How create and upload content in Cloud Storage GCP?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Thu, 09 Feb 2023 21:46:44 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-create-and-upload-content-in-cloud-storage-gcp-1fae</link>
      <guid>https://dev.to/xlmriosx/how-create-and-upload-content-in-cloud-storage-gcp-1fae</guid>
      <description>&lt;h1&gt;
  
  
  🛢 Simple way to create a bucket in Cloud Storage from GCP.
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/cloud-projects/tree/main/sdk-docker-image-from-gcp" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;All this blog is using shell.&lt;/p&gt;

&lt;p&gt;Using SDK's Google we will use tool to manage Cloud Storage. In this blog we will create a storage and upload content in it.&lt;/p&gt;

&lt;p&gt;For more information and potential of this, click &lt;a href="https://cloud.google.com/cli?hl=es-419#section-5" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Pre-Conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need have installed SDK. You can do that following next &lt;a href="https://dev.to/xlmriosx/how-install-cloud-sdk-docker-image-in-gcp-4mep"&gt;steps&lt;/a&gt;
Note: I set alias to use SDK like msdk.
---&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1st - Set a name to bucket ✍️
&lt;/h3&gt;

&lt;p&gt;We assign to a variable the name that will have bucket.&lt;/p&gt;

&lt;p&gt;I use 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;BUCKET_NAME="xlmriosx_bucket"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2nd - Create bucket ✅
&lt;/h3&gt;

&lt;p&gt;Using SDK installed with alias like msdk I use following command to create a bucket:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With alias:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mdsk gsutil mb -p $PROJECT_NAME -c $BUCKET_TYPE -l $REGION gs://$BUCKET_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Without alias:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gsutil mb -p $PROJECT_NAME -c $BUCKET_TYPE -l $REGION gs://$BUCKET_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;br&gt;
$PROJECT_NAME -&amp;gt; Is name of the project where you wnat instance a bucket.&lt;/p&gt;

&lt;p&gt;$BUCKET_TYPE -&amp;gt; Is type of storage you want, like standard, nearline, coldline, archive.&lt;/p&gt;

&lt;p&gt;$REGION -&amp;gt; Region where you want stay your storage bucket.&lt;/p&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Creating gs://xlmriosx_bucket/...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3rd - Verify that your bucket was created ✅
&lt;/h3&gt;

&lt;p&gt;We will list buckets to verify that our bucket was created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With alias:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud auth login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Without alias:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;msdk gsutil ls gs://$BUCKET_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4th - Upload content in bucket ⬆️
&lt;/h3&gt;

&lt;p&gt;We can copy content to bucket with 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;msdk gsutil cp $DATA gs://$BUCKET_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Copying file:///$DATA
[Content-Type=X]...
- [1 files][    Y.0 B/    Y.0 B]
Operation completed over 1 objects/Y.0 B.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;br&gt;
$DATA -&amp;gt; Directory or file that we want upload in the bucket.&lt;/p&gt;




&lt;h3&gt;
  
  
  5th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>announcement</category>
      <category>devto</category>
    </item>
    <item>
      <title>How install Cloud SDK Docker image from GCP?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Tue, 31 Jan 2023 23:57:19 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-install-cloud-sdk-docker-image-in-gcp-4mep</link>
      <guid>https://dev.to/xlmriosx/how-install-cloud-sdk-docker-image-in-gcp-4mep</guid>
      <description>&lt;h1&gt;
  
  
  🧰 Simple way to install SDK from GCP.
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find video related in:
&lt;/h3&gt;

&lt;p&gt;📺&lt;a href="https://youtu.be/2oHaQeKkmWI" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/cloud-projects/tree/main/sdk-docker-image-from-gcp" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;I will install Docker image to use it as a SDK in Console GCP.&lt;/p&gt;

&lt;p&gt;For more information and potential of this, click &lt;a href="https://cloud.google.com/sdk/docs/downloads-docker" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  1st - Pull Docker image ⬇
&lt;/h3&gt;

&lt;p&gt;To use the image of the latest Cloud SDK release we will need pull image from repository in console.&lt;/p&gt;

&lt;p&gt;I use following command:&lt;/p&gt;

&lt;p&gt;CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull gcr.io/google.com/cloudsdktool/cloud-sdk:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;latest: Pulling from google.com/cloudsdktool/cloud-sdk
50e431f79093: Pull complete
6005b060ba7d: Pull complete
c49059196e30: Pull complete
Digest: sha256:fd9985597827057effdb04fd1b07db9463f4a00ac24684cd3726c05e146eafa1
Status: Downloaded newer image for gcr.io/google.com/cloudsdktool/cloud-sdk:latest
gcr.io/google.com/cloudsdktool/cloud-sdk:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2nd - Verifying installation ✅
&lt;/h3&gt;

&lt;p&gt;Verify the installation (if you've pulled the latest version) by running the following command:&lt;/p&gt;

&lt;p&gt;CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run gcr.io/google.com/cloudsdktool/cloud-sdk:latest gcloud version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Google Cloud SDK 284.0.0
alpha 2020.03.06
app-engine-go
app-engine-java 1.9.78
app-engine-python 1.9.88
app-engine-python-extras 1.9.88
beta 2020.03.06
bigtable
bq 2.0.54
cbt
cloud-datastore-emulator 2.1.0
core 2020.03.06
datalab 20190610
gsutil 4.48
kubectl 2020.03.06
pubsub-emulator 0.1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3rd - Authenticate with the gcloud 👤
&lt;/h3&gt;

&lt;p&gt;We need authenticate to use gcloud tools. We can do that by the following command:&lt;/p&gt;

&lt;p&gt;CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -ti --name gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud auth login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Once we've authenticated successfully, credentials are preserved in the volume of the gcloud-config container.&lt;/p&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Go to the following link in your browser:

    https://accounts.google.com/o/oauth2/auth?...


Enter verification code: ********

You are now logged in as [xlmriosx@gmail.com].
Your current project is [xlmriosx].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4th - Creating an alias 🔤
&lt;/h3&gt;

&lt;p&gt;For simplicty create an alias by running:&lt;/p&gt;

&lt;p&gt;CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias csdk='docker run --rm --volumes-from gcloud-config -v ~/:/home/shared gcr.io/google.com/cloudsdktool/cloud-sdk'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change if you want. In my case I prefer 'csdk' like a nice alias.&lt;/p&gt;




&lt;h3&gt;
  
  
  5th - List your projects 📄
&lt;/h3&gt;

&lt;p&gt;We can list projects by two forms a large and a short.&lt;/p&gt;

&lt;p&gt;Large:&lt;br&gt;
CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud projects list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Short:&lt;br&gt;
CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;csdk gcloud projects list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PROJECT_ID              NAME              PROJECT_NUMBER
xlmriosx                xlmriosx          783709003945
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6th - Prove change of a project 🔀
&lt;/h3&gt;

&lt;p&gt;We can change name of projects by two ways a large and a short.&lt;/p&gt;

&lt;p&gt;Large:&lt;br&gt;
CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run --rm --volumes-from gcloud-config gcr.io/google.com/cloudsdktool/cloud-sdk gcloud config set project $PROJECT_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Short:&lt;br&gt;
CONSOLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;csdk gcloud config set project $PROJECT_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Updated property [core/project].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  7th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>welcome</category>
      <category>devrel</category>
      <category>community</category>
    </item>
    <item>
      <title>How working/install Pig with Notebooks?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Fri, 27 Jan 2023 00:55:32 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-workinginstall-pig-with-notebooks-54km</link>
      <guid>https://dev.to/xlmriosx/how-workinginstall-pig-with-notebooks-54km</guid>
      <description>&lt;h1&gt;
  
  
  🐷📝 Basic commands to work with Pig in Notebooks
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find post related in:
&lt;/h3&gt;

&lt;p&gt;📀&lt;a href="https://colab.research.google.com/github/xlmriosx/data-projects/blob/main/how-working-install-Pig-with-Notebooks/how_working_install_Pig_with_Notebooks.ipynb" rel="noopener noreferrer"&gt;Google Colab&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/data-projects/tree/main/how-working-install-Pig-with-Notebooks" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;I will install Hadoop with Pig program and will use a library of Python to write a job that answer the question, how many row exists by each rating?&lt;/p&gt;

&lt;p&gt;First I install Hadoop using same commands that I have used before but without put a number of step.&lt;/p&gt;




&lt;h3&gt;
  
  
  Install Hadoop 🐘
&lt;/h3&gt;

&lt;p&gt;I use following command but you can change to get current last version:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!wget https://downloads.apache.org/hadoop/common/hadoop-3.3.4/hadoop-3.3.4.tar.gz&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You would can get other version if you need in: &lt;a href="https://downloads.apache.org/hadoop/common/" rel="noopener noreferrer"&gt;https://downloads.apache.org/hadoop/common/&lt;/a&gt; and later replace it in the before command.&lt;/p&gt;




&lt;h3&gt;
  
  
  Unzip and copy 🔓
&lt;/h3&gt;

&lt;p&gt;I use following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!tar -xzvf hadoop-3.3.4.tar.gz &amp;amp;&amp;amp; cp -r hadoop-3.3.4/ /usr/local/&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Set up Hadoop's Java ☕
&lt;/h3&gt;

&lt;p&gt;I use 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;#To find the default Java path and add export in hadoop-env.sh
JAVA_HOME = !readlink -f /usr/bin/java | sed "s:bin/java::"
java_home_text = JAVA_HOME[0]
java_home_text_command = f"$ {JAVA_HOME[0]} "
!echo export JAVA_HOME=$java_home_text &amp;gt;&amp;gt;/usr/local/hadoop-3.3.4/etc/hadoop/hadoop-env.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Set Hadoop home variables 🏡
&lt;/h3&gt;

&lt;p&gt;I use 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;# Set environment variables
import os
os.environ['HADOOP_HOME']="/usr/local/hadoop-3.3.4"
os.environ['JAVA_HOME']=java_home_text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  1st - Install Pig 🐷
&lt;/h3&gt;

&lt;p&gt;I use following command but you can change to get current last version:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!wget https://downloads.apache.org/pig/pig-0.17.0/pig-0.17.0.tar.gz&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You would can get other version if you need in: &lt;a href="https://downloads.apache.org/pig/" rel="noopener noreferrer"&gt;https://downloads.apache.org/pig/&lt;/a&gt; and later replace it in the before command.&lt;/p&gt;




&lt;h3&gt;
  
  
  2nd - Unzip and copy 🔓
&lt;/h3&gt;

&lt;p&gt;I use following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!tar -xzvf pig-0.17.0.tar.gz&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3rd - Set Pig home variables 🏡
&lt;/h3&gt;

&lt;p&gt;I use 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;# Set environment variables
import os
os.environ['PIG_HOME']="/content/pig-0.17.0"
os.environ['PIG_CLASSPATH']="/usr/local/hadoop-3.3.1/conf"
os.environ["PATH"] += os.pathsep + "/content/pig-0.17.0/bin"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can validate installation with command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!pig -version&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4th - Create a folder with HDFS 🌎📂
&lt;/h3&gt;

&lt;p&gt;I use following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!/usr/local/hadoop-3.3.4/bin/hadoop fs -mkdir file:///content/data_pig&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  4.1 - Remove folder with HDFS ♻
&lt;/h4&gt;

&lt;p&gt;Maybe, later you need remove it. To do that you must apply following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!/usr/local/hadoop-3.3.4/bin/hadoop fs -rm -r file:///content/data_pig&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  5th - Getting a dataset to anlyze with Pig 💾
&lt;/h3&gt;

&lt;p&gt;I use a dataset from grouplens. You can get other in:&lt;br&gt;
&lt;a href="http://files.grouplens.org/datasets/" rel="noopener noreferrer"&gt;http://files.grouplens.org/datasets/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This time I use movieslens and you can download it using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!wget http://files.grouplens.org/datasets/movielens/ml-100k.zip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To use data extract files. I extract files in path later of -d in command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!unzip "/content/ml-100k.zip" -d "file:///content/data_pig"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For list them:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!/usr/local/hadoop-3.3.4/bin/hadoop fs -ls /content/data_pig/ml-100k&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  6th - Creating process to use Pig with Pig Syntax 🐖
&lt;/h3&gt;

&lt;p&gt;To create job in Pig, you must see structure of dataset to configure jobs.&lt;br&gt;
In this case we print dataset with following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!head /content/data_pig/ml-100k/u.data&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I can get following information of dataset:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First column reference to userID.&lt;/li&gt;
&lt;li&gt;Second column reference to movieID.&lt;/li&gt;
&lt;li&gt;Third column reference to rating.&lt;/li&gt;
&lt;li&gt;Fourth column reference to timestamp.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create pig script
%%writefile id.pig
/* id.pig */

student = LOAD 'file:///content/data_pig/ml-100k/u.data' USING PigStorage(' ')
   as (userId:int, movieId:int, rating:int, timestamp:int);

student_order = ORDER student BY rating DESC;

Dump student_order;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  7th - Running the process 🙈
&lt;/h3&gt;

&lt;p&gt;Here we run the process specifing some parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pig file program is &lt;code&gt;id.pig&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Dataset is in &lt;code&gt;file:///content/data_pig/ml-100k/u.data&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When run process, maybe take a few minutes...&lt;/p&gt;

&lt;p&gt;You can run script with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!pig -x local id.pig&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But we run script and save results in a file .txt:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!pig -x local id.pig &amp;gt; results.txt&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  8th - Advancing in the logic of the scripts 😎
&lt;/h3&gt;

&lt;p&gt;Now we will advance in logic of the script to get answer to next questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the oldest 5 star movies?&lt;/li&gt;
&lt;li&gt;What are the worst movies?&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  8.1 - Find oldest 5 star movies start ⭐
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%%writefile fiveStarMovies.pig

ratings = LOAD 'file:///content/data_pig/ml-100k/u.data'
    AS (userID:int, movieID:int, rating:int, ratingTime:int);
metadata = LOAD 'file:///content/data_pig/ml-100k/u.item' USING PigStorage('|')
    AS (movieID:int, movieTitle:chararray, releaseDate:chararray, videoRealese:chararray, imdblink:chararray);

nameLookup = FOREACH metadata GENERATE movieID, movieTitle, ToUnixTime(ToDate(releaseDate, 'dd-MMM-yyyy')) AS releaseTime;

ratingsByMovie = GROUP ratings BY movieID;

avgRatings = FOREACH ratingsByMovie GENERATE group as movieID, AVG(ratings.rating) as avgRating;

fiveStarMovies = FILTER avgRatings BY avgRating &amp;gt; 4.0;

fiveStarsWithData = JOIN fiveStarMovies BY movieID, nameLookup BY movieID;

oldestFiveStarMovies = ORDER fiveStarsWithData BY nameLookup::releaseTime;

DUMP oldestFiveStarMovies;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run script and save results in a file .txt:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!pig -x local fiveStarMovies.pig &amp;gt; fiveStarMovies.txt&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  8.2 - Find most rated bad movies ⭐
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%%writefile BadPopularMovies.pig

ratings = LOAD 'file:///content/data_pig/ml-100k/u.data'
  AS (userID:int, movieID:int, rating:int, ratingTime:int);
metadata = LOAD 'file:///content/data_pig/ml-100k/u.item' USING PigStorage('|')
    AS (movieID:int, movieTitle:chararray, releaseDate:chararray, videoRealese:chararray, imdblink:chararray);

nameLookup = FOREACH metadata GENERATE movieID, movieTitle;

groupedRating = GROUP ratings by movieID;

avgRatings = FOREACH groupedRating GENERATE group as movieID, AVG(ratings.rating) as avgRating, COUNT(ratings.rating) AS numRatings;  

badMovies = FILTER avgRatings BY avgRating &amp;lt; 2.0;

namedBadMovies = JOIN badMovies BY movieID, nameLookup BY movieID;

results = FOREACH namedBadMovies GENERATE nameLookup::movieTitle as movieName,
          badMovies::avgRating as avgRating, badMovies::numRatings as numRatings;

finalResults = ORDER results BY numRatings DESC;

DUMP finalResults;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run script and save results in a file .txt:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!pig -x local BadPopularMovies.pig &amp;gt; BadPopularMovies.txt&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  9th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>gratitude</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How install Jupyter?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Thu, 19 Jan 2023 23:58:50 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-install-jupyter-2f7j</link>
      <guid>https://dev.to/xlmriosx/how-install-jupyter-2f7j</guid>
      <description>&lt;h1&gt;
  
  
  🌰 Simple step to install and use Jupyter in windows and Linux.
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find video related in:
&lt;/h3&gt;

&lt;p&gt;📺&lt;a href="https://youtu.be/sN6y5m2qV6Y"&gt;YouTube&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/data-projects/tree/main/how-install-notebook"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;I will install Jupyter in local machine with some simple steps.&lt;/p&gt;

&lt;p&gt;Pre-Conditions: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have Python&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  1st - Clone repository ⬇
&lt;/h3&gt;

&lt;p&gt;We will need clone repository in our local machine.&lt;/p&gt;

&lt;p&gt;I use following commando:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/xlmriosx/data-projects.git&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  2nd - Go to path where is script 🏄‍♂️
&lt;/h3&gt;

&lt;p&gt;If your are in console and ran it the before command you can go to the path with 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;cd data-projects
cd how-install-notebook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3rd - Run script 🙈
&lt;/h3&gt;

&lt;p&gt;If you use Windows run the following script:&lt;br&gt;
&lt;code&gt;powershell.exe base-notebook.ps1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you use Linux run the following script:&lt;br&gt;
&lt;code&gt;sh base-notebook.sh&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>beginners</category>
      <category>python</category>
      <category>linux</category>
      <category>opensource</category>
    </item>
    <item>
      <title>How working/install Spark with Notebooks?</title>
      <dc:creator>Lucas M. Ríos</dc:creator>
      <pubDate>Mon, 16 Jan 2023 02:05:59 +0000</pubDate>
      <link>https://dev.to/xlmriosx/how-workinginstall-spark-with-notebooks-5dkf</link>
      <guid>https://dev.to/xlmriosx/how-workinginstall-spark-with-notebooks-5dkf</guid>
      <description>&lt;h1&gt;
  
  
  🌟📝 Basic commands to work with Spark in Notebooks like a Standalone cluster
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🔗Related content
&lt;/h2&gt;

&lt;h3&gt;
  
  
  You can find post related in:
&lt;/h3&gt;

&lt;p&gt;📀&lt;a href="https://colab.research.google.com/drive/1jKDMz7bxJa0hBhyeJ2kuzhr3ejythIIe?usp=sharing"&gt;Google Collab&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can find video related in:
&lt;/h3&gt;

&lt;p&gt;📺&lt;a href="https://youtu.be/KxNzlGv1cKQ"&gt;YouTube&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can find repo related in:
&lt;/h3&gt;

&lt;p&gt;🐱‍🏍&lt;a href="https://github.com/xlmriosx/How-working-install-spark-with-Notebooks"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  You can connect with me in:
&lt;/h3&gt;

&lt;p&gt;🧬&lt;a href="https://www.linkedin.com/in/xlmriosx/"&gt;LinkedIn&lt;/a&gt; &lt;/p&gt;




&lt;h3&gt;
  
  
  Resume 🧾
&lt;/h3&gt;

&lt;p&gt;I will install Spark program and will use a library of Python to write a job that answer the question, how many row exists by each rating?&lt;/p&gt;

&lt;p&gt;Before start we setup environment to run Spark Standalone Cluster.&lt;/p&gt;




&lt;h3&gt;
  
  
  1st - Mount Google Drive 🚠
&lt;/h3&gt;

&lt;p&gt;We will mount Google Drive to can use it files.&lt;/p&gt;

&lt;p&gt;I use following script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from google.colab import drive
drive.mount('/content/gdrive')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2nd - Install Spark 🎇
&lt;/h3&gt;

&lt;p&gt;Later got a Colab notebook up, to get Spark running you have to run the following script (I apologize for how ugly it is).&lt;/p&gt;

&lt;p&gt;I use following script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%%bash
apt-get install openjdk-8-jdk-headless -qq &amp;gt; /dev/null 
if [[ ! -d spark-3.3.1-bin-hadoop3.tgz ]]; then
  echo "Spark hasn't been installed, Downloading and installing!"
  wget -q https://downloads.apache.org/spark/spark-3.3.1/spark-3.3.1-bin-hadoop3.tgz
  tar xf spark-3.3.1-bin-hadoop3.tgz
  rm -f spark-3.3.1-bin-hadoop3.tgz

fi
pip install -q findspark
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You would can get other version if you need in: &lt;a href="https://downloads.apache.org/spark/"&gt;https://downloads.apache.org/spark/&lt;/a&gt; and later replace it in the before command.&lt;/p&gt;




&lt;h3&gt;
  
  
  3rd - Setting environment variables 🌐
&lt;/h3&gt;

&lt;p&gt;I use 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;import os
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64"  
os.environ["SPARK_HOME"] = "/content/spark-3.3.1-bin-hadoop3"
import findspark
findspark.init()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4th - Configuring a SparkSession 🚪
&lt;/h3&gt;

&lt;p&gt;I use 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;from pyspark.sql import SparkSession
spark = SparkSession.builder \
    .master("local[*]") \ # set up like master using all(*) threads
    .appName("BLOG_XLMRIOSX") \ # a generic name
    .getOrCreate()
sc = spark.sparkContext
sc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later of execute this we can use many data strcuture to manage data, like RDD and Dataframe(Spark and Pandas).&lt;br&gt;
Exists one more but only exists in Scala and it is Dataset.&lt;/p&gt;




&lt;h3&gt;
  
  
  5th - Getting a dataset to anlyze with Spark 💾
&lt;/h3&gt;

&lt;p&gt;I use a dataset from grouplens. You can get other in:&lt;br&gt;
&lt;a href="http://files.grouplens.org/datasets/"&gt;http://files.grouplens.org/datasets/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This time I use movieslens and you can download it using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!wget http://files.grouplens.org/datasets/movielens/ml-100k.zip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To use data extract files. I extract files in path later of -d in command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!unzip "/content/ml-100k.zip" -d "/content/ml-100k_folder"&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  6th - Configuring data to analyze 💿
&lt;/h3&gt;

&lt;p&gt;We create a variable called data where put path where data is like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;data = '/content/ml-100k_folder/ml-100k/u.data'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Later define a variable called df_spark where put information of data:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;df_spark = spark.read.csv(data, inferSchema=True, header=True)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can inspect type of variable df_spark like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;print(type(df_spark))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can inspect data frame of variable df_spark like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;df_spark.show()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can see format is incorrect so we will fix that where we configure format of data by following way:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;df_spark = spark.read.csv(data, inferSchema=True, header=False, sep="\t")&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  9th - Making a query 🙈
&lt;/h3&gt;

&lt;p&gt;To make this we need know format of data, so I infer the following structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First column reference to userID.&lt;/li&gt;
&lt;li&gt;Second column reference to movieID.&lt;/li&gt;
&lt;li&gt;Third column reference to rating.&lt;/li&gt;
&lt;li&gt;Fourth column reference to timestamp.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will answer the question, how many movies by each rating exists...&lt;/p&gt;




&lt;h4&gt;
  
  
  9th - Making a query with SQL syntax ❔🛢
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;First, create a table with dataframe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;df_spark.createOrReplaceTempView("table")&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Second, can make query to answer question.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;sql = spark.sql("SELECT _c2, COUNT(*) FROM table GROUP BY _c2")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To see results:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sql.show()&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  9th - Making a query with Dataframe ❔📄
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It's so easy make this query with dataframe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;dataframe.groupBy("_c2").count().show()&lt;/code&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  9th - Making a query with RDD ❔🧊
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;First, we transform dataframe to rdd type.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;rdd = df_spark.rdd&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Second, make query with RDD functions.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rdd\
.groupBy(lambda x: x[2])\
.mapValues(lambda values: len(set(values)))\
.collect()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10th - Say thanks, give like and share if this has been of help/interest 😁🖖
&lt;/h3&gt;




</description>
      <category>python</category>
      <category>datascience</category>
      <category>bigdata</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
