From 6cc72adeab9d24b9b4b32de695f3a57320f9c533 Mon Sep 17 00:00:00 2001 From: Jan Beilicke Date: Thu, 26 Nov 2020 07:56:51 +0000 Subject: [PATCH] Windows 10: Added a simpler way to provision a VM just by using Vagrant (no WSL required) Ansible will be installed by Vagrant in the VM and will then provision the machine from within, making the Windows Subsystem for Linux obsolete. The Vagrant host (Windows 10) only has to have Vagrant installed. --- README.md | 38 +++++++++++++++++++++++++++----------- Vagrantfile | 24 +++++++++++++++++++++--- inventory.ini.sample | 2 +- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 0b95971..c83cc0d 100644 --- a/README.md +++ b/README.md @@ -47,16 +47,6 @@ The main goals of this project are: To give SATT a quick spin, you could easily bootstrap a development VM using Vagrant on your local machine. -### Vagrant + Ansible on Windows 10 using Windows Subsystem for Linux - -1. [Download](https://www.virtualbox.org/wiki/Downloads) and install Virtualbox ([Documentation](https://www.virtualbox.org/wiki/End-user_documentation)) - -2. Follow the [guide to install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). This SATT guide assumes Ubuntu 18.04 LTS - -3. Open Ubuntu through the Windows Start Menu - -4. Inside the Ubuntu Terminal, continue the setup by following the next section. - ### Vagrant + Ansible on Linux 1. Obtain Vagrant by [downloading the corresponding package](https://www.vagrantup.com/downloads.html) for your distribution, assuming Ubuntu in the next steps. @@ -111,7 +101,33 @@ By default, a `vagrant` user will be provisioned (if not already available) and **IMPORTANT**: Pay attention to the [Firewall](#firewall) section below. -## Quickstart: Regular server/VM +### Vagrant on Windows 10 (no Ansible required) + +Vagrant will bootstrap a VM, install Ansible und run the provisioning from within the VM, i.e. the Vagrant host does not need to have any Ansible installed. + +1. [Download](https://www.virtualbox.org/wiki/Downloads) and install Virtualbox ([Documentation](https://www.virtualbox.org/wiki/End-user_documentation)) + +2. Obtain Vagrant by [downloading and installing the corresponding package](https://www.vagrantup.com/downloads.html) + +3. Clone this repository with Git or download and extract an archive + +4. Open a Command Prompt or Powershell window and navigate to the checked out repository / extracted archive. + +5. Run Vagrant with: `vagrant up` and wait patiently. + +### Vagrant on Windows 10 using Windows Subsystem for Linux + Ansible + +This approach will install Vagrant and Ansible in a Linux box using WSL. Vagrant will provision the VM with Ansible from the Vagrant host over SSH. + +1. [Download](https://www.virtualbox.org/wiki/Downloads) and install Virtualbox ([Documentation](https://www.virtualbox.org/wiki/End-user_documentation)) + +2. Follow the [guide to install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10). This SATT guide assumes Ubuntu 18.04 LTS + +3. Open Ubuntu through the Windows Start Menu + +4. Inside the Ubuntu Terminal, continue the setup by following the next section. + +## Quickstart: Regular Linux server/VM - Clone this repo - Install dependencies (roles): `ansible-galaxy install -r requirements.yml` diff --git a/Vagrantfile b/Vagrantfile index 801acf7..dbb54fe 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -54,11 +54,29 @@ Vagrant.configure(2) do |config| # https://www.virtualbox.org/manual/ch06.html#network_nat_service dev.vm.network :private_network, ip: "192.168.23.42" - dev.vm.provision :ansible do |ansible| + # Provision the VM from the Vagrant host. + # The host has to have Ansible installed and will connect to the VM via SSH + # dev.vm.provision :ansible do |ansible| + # #ansible.verbose = "vvv" + # ansible.compatibility_mode = "2.0" + # ansible.playbook = "site.yml" + # ansible.inventory_path = "inventory.ini.sample" + # ansible.become = true + # end + + # Provision by running Ansible from within the VM. + # Vagrant will try to install Ansible automatically using pip + # Advantage: Ansible doesn't have to be installed on the Vagrant host + # See also: https://www.vagrantup.com/docs/provisioning/ansible_local.html + dev.vm.provision "ansible_local" do |ansible| #ansible.verbose = "vvv" ansible.compatibility_mode = "2.0" - ansible.playbook = "./site.yml" - ansible.inventory_path = "./inventory.ini.sample" + ansible.install_mode = "pip" + ansible.version = "2.10.3" + ansible.playbook = "site.yml" + #ansible.inventory_path = "inventory.ini.sample" + ansible.galaxy_role_file = "requirements.yml" + ansible.galaxy_roles_path = "roles" ansible.become = true end end diff --git a/inventory.ini.sample b/inventory.ini.sample index f4eea77..c06c8db 100644 --- a/inventory.ini.sample +++ b/inventory.ini.sample @@ -1,5 +1,5 @@ # All hosts -satt ansible_user=vagrant ansible_host=192.168.23.42 +satt ansible_user=vagrant [vagrant] satt