\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Carlos99} \pdfinfo{ /Title (tutorial-vagrant.pdf) /Creator (Cheatography) /Author (Carlos99) /Subject (Tutorial Vagrant Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{B23DC4} \definecolor{LightBackground}{HTML}{FAF2FB} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Tutorial Vagrant Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Carlos99} via \textcolor{DarkBackground}{\uline{cheatography.com/193978/cs/40404/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Carlos99 \\ \uline{cheatography.com/carlos99} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 22nd September, 2023.\\ Updated 22nd September, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Definiciones}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Vangrant}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Es una {\bf{herramienta que simplifica el trabajo}} para ejecutar y gestionar máquinas virtuales creada por Hashicorp} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Vangrantfile}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}En este fichero está {\bf{guardada la configuración de las MVs}} usadas} \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Atlas}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Servicio usado por Vangrant para {\bf{descargar {\emph{'base boxes'}} }}} \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Packer}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Herramienta de línea de comandos que {\bf{automatiza la creación de MVs}} con distintos sistemas y proveedores} \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Boxes}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Vagrant utiliza {\bf{imágenes preconstruidas de máquinas virtuales}} llamadas "cajas" (boxes)} \tn % Row Count 18 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{ {\bf{Requisitos previos:}} VirtualBox instalado, estación de trabajo con más de 4 GB de RAM}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Vagrant vs Docker}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Si utilizas Virtualbox o Vmware como el proveedor para Vagrant, puede iniciar una máquina virtual según las configuraciones en el archivo Vagrantfile. \newline % Row Count 4 (+ 4) Si utilizas Docker como el proveedor para Vagrant, entonces lanzará contenedores de Docker según las configuraciones en el archivo Vagrantfile.% Row Count 8 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.28482 cm} x{1.69218 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comandos básicos}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{\$ vagrant -{}-version}} & consultar la versión \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{\$ export VAGRANT\_HOME=}} /ruta/al/directorio & \seqsplit{configuración} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{\$ vagrant}} | {\bf{\$ vagrant -h}} & ayuda \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{\$ vagrant init}} & crear Vagrantfile \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Configuración del Vagrantfile}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Especificar la box a utilizar}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}config.vm.box = "ubuntu/bionic64"} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Definir el nombre de la MV}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}config.vm.define "mi\_vm"} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Modificar RAM y nº de núcleos}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}config.vm.provider "virtualbox" do |vb| vb.memory = 1024 vb.cpus = 2 end} \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Configuración de red}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}config.vm.network "forwarded\_port", guest: 80, host: 8080 config.vm.network "private\_network", type: "dhcp"} \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{Entorno gráfico}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}vb.gui = true} \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Configurar un disco}}} \tn \mymulticolumn{1}{x{5.377cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}vb.customize {[}'createhd', '-{}-filename', 'additional\_disk.vdi', '-{}-size', 500 * 1024{]} vb.customize {[}'storageattach', :id, '-{}-storagectl', 'SATA Controller', '-{}-port', 1, '-{}-device', 0, '-{}-type', 'hdd', '-{}-medium', 'additional\_disk.vdi'{]}} \tn % Row Count 20 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Boxes}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{\$ vagrant box add}} {\emph{{[}nombre{]} {[}URL o ruta local{]}}} & agregar un nuevo box a Vagrant \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{\$ vagrant box list}} & mostrar la lista de boxes instaladas \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{\$ vagrant box remove}} {\emph{{[}nombre{]}}} & eliminar un box específico \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} {\bf{\$ vagrant box update}} & actualizar las boxes si es necesario \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{\$ vagrant box outdated}} & mostrar la lista de las actualizaciones requeridas \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} {\bf{\$ vagrant box repackage}} {\emph{{[}nombre{]} {[}versión{]}}} & empaquetar una box existente en una nueva versión \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Inicio máquina virtual}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{El proceso de arranque de la máquina son 3 etapas: \newline % Row Count 2 (+ 2) {\bf{1.-}} Descarga e instalación de la 'box' en el sistema anfitrión. \newline % Row Count 4 (+ 2) `\textasciitilde{}/.vagrant.d/boxes` \newline % Row Count 5 (+ 1) {\bf{2.-}} Importación de la 'box' al proyecto. \newline % Row Count 7 (+ 2) `\textasciitilde{}/VirtualBox VMs/` \newline % Row Count 8 (+ 1) {\bf{3.-}} Arranque del sistema.% Row Count 9 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{La imagen utilizada para la máquina virtual se almacena en un archivo llamado {\bf{"box file"}} con extensión {\bf{.box}} }}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Compartir carpeta entre MV y Host}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`{\bf{config.vm.synced\_folder}} {\emph{"." {\bf{}},}} {\emph{"/vagrant"}} {\bf{, \{\{nl\}\} type:}} {\emph{"virtualbox"}}`% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Gestión MV}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{\$ vagrant up}} & iniciar la máquina virtual \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{\$ vagrant halt {[}ID{]}}} & detener la máquina virtual \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{\$ vagrant destroy {[}ID{]}}} & eliminar la máquina virtual \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\emph{Los IDs de las máquinas virtuales se pueden consultar utilizando el comando {\bf{\$ vagrant global-status}} }}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Crear entornos múltiples MVs}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Fichero Vagrantfile, instalar y arrancar Ubuntu y Debian:}} \newline % Row Count 2 (+ 2) `{\bf{Vagrant.configure(}} {\emph{"2"}} {\bf{) do |config| \{\{nl\}\} config.vm.define}} {\emph{"ubuntu"}} {\bf{do |ubuntu| \{\{nl\}\} ubuntu.vm.box =}} {\emph{"bento/ubuntu-16.04"}} \{\{nl\}\} {\bf{end}} \{\{nl\}\} {\bf{config.vm.define}} {\emph{"ubuntu"}} {\bf{do |debian| \{\{nl\}\} debian.vm.box =}} {\emph{"debian/jessie64"}} \{\{nl\}\} {\bf{end}} \{\{nl\}\}{\bf{end}}` \newline % Row Count 9 (+ 7) {\bf{Fichero Vagrantfile: instalar y arrancar dos nodos (nodo1 y nodo2) de una misma distribución}} {\emph{centos/7}}: \newline % Row Count 12 (+ 3) `{\bf{Vagrant.configure(}} {\emph{"2"}} {\bf{) do |config| \{\{nl\}\} config.vm.define}} {\emph{"nodo1"}} {\bf{do |nodo1| \{\{nl\}\} nodo1.vm.box =}} {\emph{"centos/7"}} \{\{nl\}\} {\bf{nodo1.vm.hostname =}} {\emph{'nodo1'}} \{\{nl\}\} {\bf{nodo1.vm.network}} {\emph{"public\_network"}}, \{\{nl\}\} {\bf{ip:}} {\emph{"192.168.1.24"}}\{\{nl\}\} {\bf{end}} \{\{nl\}\}{\bf{end}}`% Row Count 18 (+ 6) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Primera Imagen}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Creación de la imagen:}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{\$ mkdir}} {\emph{box-factory}} \{\{nl\}\} {\bf{\$ cd}} {\emph{box-factory}} & creación del directorio \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{\$ vagrant init -m}} {\emph{ubuntu/trusty32}} & iniciar nuevo proyecto en una imagen existente \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} {\bf{\$ vagrant up}} & levantar máquina virtual \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{\$ vagrant ssh \{\{nl\}\} \$ jeky11 -{}-version \{\{nl\}\} \$ vagant package}} {\emph{-{}-output box-jeky11.box}} & iniciar sesión ssh \{\{nl\}\} comprobar versión \{\{nl\}\} crear la imagen de la máquina virtual \tn % Row Count 14 (+ 5) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Gestión de imágenes:}}} \tn % Row Count 15 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{\$ vagrant box list}} & consultar la lista de boxes (imágenes) \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} {\bf{\$ vagrant box add}} {\emph{{[}nombre{]} {[}Direccion{]}}} & añadir una nueva imagen al sistema \tn % Row Count 20 (+ 3) % Row 8 \SetRowColor{LightBackground} {\bf{\$ vagrant box remove}} {\emph{{[}nombre{]}}} & eliminar una imagen del sistema \tn % Row Count 22 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Imágenes con chef/bento}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{\$ git clone {\emph{https://github.com/chef/bento.git}} \{\{nl\}\} \$ cd bento}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{\$ packer build}} {\emph{-{}-only=virtualbox-iso ubuntu-14.04-i386.json}} & construir la imagen de Ubuntu para VirtualBox \tn % Row Count 6 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Seguridad}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.08574 cm} x{1.89126 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Riesgo \#1 Descarga de la imagen de internet}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Al descargar una imagen de una fuente no fiable para crear una máquina virtual} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{\$ vagrant box add}} {\emph{{[}nombre{]} {[}URL o ruta local{]}}} & agregar una box a Vagrant \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} {\bf{\$ vagrant box list}} & lista de boxes instaladas \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} {\bf{\$ vagrant box remove}} {\emph{{[}nombre{]}}} & eliminar una box \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Riesgo \#2 Exposición de puertos}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Vagrant por defecto redirige solo un puerto, el SSH, desde el sistema invitado y no debe exponer otros servicios a la red} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{\$ config.vm.network :forwarded\_port, guest:}} {\emph{{[}puerto\_invitado{]}}}, {\bf{host:}} {\emph{{[}puerto\_anfitrión{]}}}, {\bf{host\_ip:}} {\emph{"127.0.0.1"}} & configurar la redirección de puertos para el sistema invitado en el archivo Vagrantfile \tn % Row Count 10 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Riesgo \#3 Credenciales Predeterminadas}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Las credenciales predeterminadas de Vagrant, como el usuario {\emph{"vagrant"}} con permisos de sudo, pueden ser un riesgo de seguridad si no se cambian.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{\$ vagrant ssh}} & iniciar una sesión SSH en la máquina virtual utilizando las credenciales predeterminadas \tn % Row Count 7 (+ 4) % Row 2 \SetRowColor{LightBackground} {\bf{\$ passwd}} & modificar la contraseña del usuario "vagrant" en la máquina virtual \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Riesgo \#4 Llaves RSA predeterminadas}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Todas las imágenes descargadas de Internet incluyen las mismas llaves RSA, lo que puede representar un riesgo si no se cambian.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{\$ vagrant ssh}} & iniciar una sesión SSH en la máquina virtual utilizando las llaves predeterminadas. \tn % Row Count 7 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Proyecto Sinatra}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{\$ vagrant ssh \{\{nl\}\} \$ ruby app.rb -o 0.0.0.0 \& \{\{nl\}\} \$ logout}} & iniciar el servidor HTTP \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} {\bf{config.vm.network :forwarded\_port, guest:}} {\emph{4567}}, {\bf{host:}} {\emph{9090}}, {\bf{host\_ip:}} {\emph{"127.0.0.1"}} & si el puerto está ocupado en nuestro sistema, hay que cambiarlo en el fichero Vagrantfile \tn % Row Count 9 (+ 5) % Row 2 \SetRowColor{LightBackground} {\bf{\$ vagrant reload}} & aplicar los cambios \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Acceder a root directamente}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Para acceder remotamente lo haremos mediante el SSH} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{cp -r}} {\emph{/home/vagrant/.ssh/ /root/}} \{\{nl\}\} {\bf{chown -R}} {\emph{root.root /root/.ssh/}}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Modificar el usuario SSH en Vagrantfile: \{\{nl\}\} {\bf{config.ssh.username =}} {\emph{"root"}}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Usar Ansible para ejecutar comandos en máquinas Vagrant habilitadas con sudo} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{ansible -vv all -m command -a "id" -u vagrant -{}-private-key}} {\emph{/ruta/a/la/clave/privada}} {\bf{-b -{}-become-method sudo -e "ansible\_become\_pass=contraseña"}}} \tn % Row Count 12 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{ansible -vv all -m command -a "id" -u vagrant -{}-private-key}} {\emph{/ruta/a/la/clave/privada}} {\bf{-b}}} \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}