Quickly spin a local Ansible control node with Vagrant + VirtualBox.
For more context, read the accompanying blog post.
$ git clone https://github.com/Eigenbahn/vagrant-ansible-control-node
$ cd vagrant-ansible-control-node
$ vagrant up
# [...]
$ vagrant ssh
Some stuff can be tweaked in the Vagrantfile:
config.vm.network
: the private IP address to access your host via SSH. If you only usevagrant ssh
to connect, you don't care about this.config.vm.synced_folder
: A host folder to mount onto the guest filesystem. Multiple entries are allowed.vb.name
: the alias given to the VirtualBox VM / Vagrant machinevb.memory
: the amount of RAM (in MB) allocated to the VM
Additionally, you can adjust a few variables in the ansible provisioning script:
my_reinstall_ansible_from_ppa
: Whenyes
, reinstall Ansible from the bleeding edge official Ansible PPA. Defaults tono
.my_disable_ansible_host_key_change_check
: Whenyes
, Ansible won't complain when the identity of a remote host changes. Defaults toyes
.my_ansible_additonal_role_path
: When set, additional folders when roles are stored. Separator is:
.my_ansible_nb_parallel_targets
: When set, number of hosts that can be provisioned in parallel.
We let Vagrant install Ansible itself by relying on the Ansible Local Provisioner.
2 instances of the provisioning scripts get launched sequentially:
- normalize: make the machine more compliant with Vagrant recommandations
- ansible: tweak Ansible, eventually reinstall a more recent version
I choose to use a Debian base box as I'm more familiar with this familly of distribution.
I selected the official Debian 10 box.
I also projected using generic/debian10 from the Roboxes project but it came bundled with an old version of VirtualBox guest additions.
Likewise, official Ubuntu boxes are also great but have an issue with slow startup time.
A lot of boxes only come with SSH authentication by key.
As per official recommandations, we also set the vagrant
and root
users password to vagrant
and authorize SSH by password.
We also authorize SSH as root.
- Disposable Infrastructure post series from Exclamation Labs documents using an old Ubuntu 14.04 base box and installs Ansible from the official PPA. Provisoning is done via an inline shell script.
- baldoarturo/ansible-control-node uses an old Ubuntu 16.04 base box and installs Ansible from the official PPA. Provisoning is done via an inline shell script.
If you're an Emacs user, you might want to check out package magrant for a tighter integration with Vagrant cli commands.