К основному контенту

Сообщения

Сообщения за сентябрь, 2018

How to create a vagrant VM from a libvirt vm/image

It cost's me some nerves and time to figure out how to create a vagrant image from a libvirt kvm vm and how to modify an existing one. Thanks to pl_rock from stackexchange for the awesome start. First of all you have to install a new vm as usual. I've installed a new vm with Ubuntu 16.04 LTS. I'm not sure if it's really neccessary but set the root password to "vagrant", just to be sure. Connect to your VM via ssh or terminal and do the following steps. Create a new user for vagrant: adduser vagrant Vagrant user should be able to run sudo commands without a password prompt: sudo visudo -f /etc/sudoers.d/vagrant vagrant ALL=(ALL) NOPASSWD:ALL Install ssh-server if that's not already done: sudo apt-get install -y openssh-server Create a home directory for your vagrant user and also get the master key: mkdir -p /home/vagrant/.ssh chmod 0700 /home/vagrant/.ssh wget --no-check-certificate \ https://raw.github.com/mitchellh/vagrant/master/keys/vag...

Testing Ansible Roles using Molecule and Vagrant

Ansible Ansible is a radically simple IT automation engine that automates cloud provisioning , configuration management , application deployment , intra-service orchestration , and many other IT needs. TestInfra With Testinfra you can write unit tests in Python to test actual state of your servers AND/OR ServerSpec With Serverspec, you can write RSpec tests for checking your servers are configured correctly. And Molecule Molecule is designed to aid in the development and testing of Ansible roles including support for multiple instances, operating system distributions, virtualization providers and test frameworks. Getting started with molecule Installing molecule $ pip install molecule molecule --version Create an Ansible Role $ molecule init test-role-vagrant Successfully initialized new role in ./test-role-vagrant This will create an ansible role with the following directory structure test-role-vagrant ├── README.md ├── defaults │ └...

Testing your Ansible roles with Vagrant

In ansible , development , vagrant Travis.ci offers a simple and free way to test your Ansible roles but that’s after you’ve pushed and published your code. What if you want to verify how a change looks on a machine or easily see that build error without using an existing machine? This led me down the path of locally provisioning a virtual machine and outside of a normal virtual machine that I have running, I just wanted a standalone build just for a role. I first went down the Docker route since that’d give me a good starting point but I still enjoy the simplicity of a Vagrant controlled virtual machine. The CLI is incredibly simple and you can easily swap out the base box to test on different distros if you’d like. Also, Vagrant has an ansible_local provisioner that makes it as simple as pointing it at your test playbook to run which I already have in place for Travis.ci. The setup for this is based ...