Monday, August 8, 2016

Using Ansible Vault in Vagrant

While using ansible with vagrant, there are cases where we need to run Ansible manually when  we use Ansible vault. Now vagrant provides facilities in allowing vagrant use Ansible vault when starting the remote machine.

We can make vagrant to ask for the Ansible vault password while starting the remote machine by passing the Ansible raw arguments.

Check the vagrantfile below,

[root@puppet sshkeys]# cat Vagrantfile
Vagrant.configure(2) do |config| = "geerlingguy/centos7"
   config.vm.host_name = "sshdev.foohost.vm"

   config.vm.provider :virtualbox do |vb| = "SSHFooBarhost" #Name of the Virtual
       vb.customize ["modifyvm", :id , "--cpus", 4]

 config.vm.provision “Ansible” do |ansible|
    ansible.playbook =  “playbook.yml”
    Ansible.raw_arguments = “ –ask-vault-pass”


The above snippet will allow vagrant to ask for the vault password when using Ansible playbook which has the vault configuration.

More to come , Happy learning J

1 comment :

  1. What's up, just wanted to tell you, I loved this blog post.

    It was inspiring. Keep on posting!