Cookie Consent by Free Privacy Policy Generator 📌 Provisioning Ansible on Ubuntu with Vagrant and Virtual box

✅ Provisioning Ansible on Ubuntu with Vagrant and Virtual box

💡 Newskategorie: Programmierung
🔗 Quelle:


Automation tools play a crucial role in day-to-day software development jobs. And it is on that note that Ansible has proven to be one of the most used technologies in today's software development world.

Ansible is an open-source software development tool that enables infrastructure as code (IaC). Ansible helps in:

  • Software provisioning - Ansible can prepare your servers with the necessary software and settings.
  • Configuration management - Ansible can manage system configurations to ensure your systems and servers are in the desired state
  • Application deployment - Ansible can automate the process of deploying applications to servers.

Ansible is agentless. It relies on temporary remote connections via SSH. Ansible uses a human-readable script called Playbook to automate tasks and manage and maintain system configurations.

Vagrant on the other hand is an open-source software that provides a convenient way to manage virtual environments making it easier to replicate virtual environments across different hosts.

Meanwhile, VirtualBox is a free open-source virtualization platform. Together with Vagrant, they provide a seamless solution for creating and maintaining virtual machines.

This article aims to guide us through the process of setting up a local environment with Ansible on Ubuntu with Vagrant and VirtualBox where we will run a simple Ansible playbook on the local machine to print “Hello World”.


Software requirements

  • Ubuntu
  • Vagrant
  • Virtual Box Basic Knowledge of Linux commands

Setting up Ubuntu virtual machine with Vagrant and VirtualBox

To begin we will need to download and install Vagrant and VirtualBox

  1. Installing VirtualBox Virtual Box is a free and open-source technology available for download for different operating systems.
  2. Download VirtualBox: visit the VirtualBox download page to download the appropriate version for your operating system
  3. Install virtual box: Install the virtual box application from the downloaded binary.

  4. Installing Vagrant

  5. Download Vagrant: Download Vagrant from the Vagrant download page

  6. Install Vagrant: Follow the installation guide to install Vagrant for your specific operating system. Vagrant will be automatically added to your system path, so you can start using vagrant commands from your terminal.

  7. Verify Installation: to verify that Vagrant was installed correctly execute the command below to see if it prints out the installed version.
    vagrant -version

Creating an Ubuntu Virtual Machine

For the sake of this article, we will be using PowerShell. Run it as an administrator.

  • We will need to create a folder to store all our vagrant-related files, we will call the file. To do that run the following command.
    mkdir ansibleProject

  • Cd into the directory with
    cd ansibleProject

  • Initialise a vagrant file with an Ubuntu image. This will contain all the necessary configurations needed for our virtual machine. We are going to use the Ubuntu image available in the Vagrant cloud.
    vagrant init

  • Start the virtual machine with the following command
    Vagrant up

The above command will download the ubuntu/trusty64 virtual machine image from the vagrant cloud and start the VM.

It also creates a key pair so we can SSH into the machine once it is done setting up.

You can check the status of the virtual machine with the following command vagrant status. It should print out “running (virtualbox)”. we can also check the status by opening VirtualBox to see if our virtual machine is up and running.
SSH into the virtual machine by running the following command vagrant ssh

Installing Ansible

To install Ansible on our virtual machine running on Ubuntu we need to run the following commands.

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

As soon as Ansible is done installing, we will verify if it was installed correctly.

To verify that Anisble was installed correctly run the following command
ansible –version.

Creating a playbook

  1. To create a playbook, we will first create a new directory. This will contain our ansible playbook.
    mkdir ansible-project

  2. Create a new file called playbook.yml. This file will contain the task you want to perform on your machine.
    Touch playbook.yml
    Run ls to see if it was created successfully.

  3. Write your playbook in the playbook.yml file

To do this:

  • Open the playbook.yml by running vi playbook.yml
  • Press “I” on your keyboard to enter Insert mode. Copy and paste the following:
- name: Basic playbook
  hosts: localhost
    - name: Print a message
        msg: "Hello, World!"
  • Hit the “esc” key when done, to exit insert mode.
  • Type “:wq!” to exit and save the playbook.yml

This is a simple playbook script that tells Ansible to connect to a machine, in this case, localhost which is the machine Ansible is installed on.

Then tells the machine to print “Hello world”

run the playbook by running ansible-playbook playbook.yml


In this simple guide, we’ve seen how to set up a development environment on Ubuntu using Vagrant and VirtualBox, followed by installing Ansible for automation and configuration management.

With Ansible installed we have a powerful tool that can help reduce repetitive tasks and increase productivity.

We can take this further by automating configurations on the cloud with Ansible rather than on our local machines.

As we continue our journey, whether we are managing a small infrastructure or orchestrating a complex deployment Ansible simplicity makes it a great addition in our DevOps toolkit.
Don’t stop learning!


✅ Provisioning Ansible on Ubuntu with Vagrant and Virtual box

📈 64.68 Punkte

✅ Automate homelab microK8s cluster provisioning with Vagrant and Ansible

📈 45.66 Punkte

✅ Hashicorp vagrant-vmware-fusion bis 5.0.2 Vagrant Update Process erweiterte Rechte

📈 35.18 Punkte

✅ Hashicorp vagrant-vmware-fusion up to 5.0.2 Vagrant Update Process privilege escalation

📈 35.18 Punkte

✅ Vermin (a modern CLI for vagrant) - Now supports managing Vagrant Boxes

📈 35.18 Punkte

✅ Automate access provisioning and de-provisioning for employee onboarding and offboarding

📈 32.24 Punkte

✅ Cisco Prime Collaboration Provisioning Tool Batch Provisioning File Directory Traversal

📈 29.17 Punkte

✅ Cisco Prime Collaboration Provisioning Batch Provisioning erweiterte Rechte

📈 29.17 Punkte

✅ Cisco Prime Collaboration Provisioning Tool Batch Provisioning File directory traversal

📈 29.17 Punkte

✅ Cisco Prime Collaboration Provisioning Batch Provisioning privilege escalation

📈 29.17 Punkte

✅ Vagrant - Installation and how to create the first box

📈 26.75 Punkte

✅ Provisioning Infrastructure with Ansible

📈 26.54 Punkte

✅ Ansible as a Provisioning tool: Creating a VPC

📈 26.54 Punkte

✅ How to Create and Manage Virtual Machines with the Vagrant Command Line Tool

📈 26.13 Punkte

✅ How to Enable a Virtual Machine on Your Windows Laptop With Vagrant and Git Bash

📈 26.13 Punkte

✅ Install Virtual Machine With Vagrant & Remotely Access it

📈 24.6 Punkte

✅ Understanding CSS Box Sizing: A Guide to 'content-box' and 'border-box'

📈 24.41 Punkte

✅ Ansible ansible.cfg erweiterte Rechte

📈 23.9 Punkte

✅ Ansible ansible.cfg privilege escalation

📈 23.9 Punkte

✅ Ansible Engine/Ansible Tower Decryption /tmp temp file

📈 23.9 Punkte

✅ Ansible Engine/Ansible Tower ldap_attr/ldap_entry bind_pw Credentials information disclosure

📈 23.9 Punkte

✅ Ansible Engine/Ansible Tower fuse Filesystem Temporary temp file

📈 23.9 Punkte

✅ Ansible vs Ansible Tower: What are The Key Differences | UpGuard

📈 23.9 Punkte

✅ regex to do something like s/^ansible:x:{*}:/ansible:x:1234567:/g

📈 23.9 Punkte

✅ CVE-2021-3620 | Red Hat Ansible prior 2.9 ansible-connection information exposure

📈 23.9 Punkte

✅ CVE-2021-3533 | Red Hat Ansible Tower/Ansible Automation Platform toctou

📈 23.9 Punkte

✅ CVE-2021-3532 | Red Hat Ansible Tower/Ansible Automation Platform Async Status information disclosure

📈 23.9 Punkte

✅ CVE-2019-14858 | Red Hat Ansible Engine/Ansible Tower Invalid Parameter log file

📈 23.9 Punkte

✅ heise-Angebot: iX-Workshop: Ansible Automation Plattform (AAP) und Event Driven Ansible (EDA)

📈 23.9 Punkte

✅ Ansible Semaphore - A Modern UI for Ansible

📈 23.9 Punkte

✅ heise-Angebot: iX-Workshop: Ansible Automation Plattform (AAP) und Event-driven Ansible (EDA)

📈 23.9 Punkte

✅ heise-Angebot: iX-Workshop: Ansible Automation Plattform (AAP) und Event-driven Ansible (EDA)

📈 23.9 Punkte

✅ Deep Dive with Ansible: Patching an Ansible Collection

📈 23.9 Punkte


Datei nicht gefunden!