Adds a simple way to provision the VM from within the VM by letting Vagrant install Ansible and run it locally.

This commit is contained in:
Jan Beilicke 2020-11-25 22:39:37 +00:00
parent 9216a85f10
commit 22c84f6122
3 changed files with 20 additions and 5 deletions

21
Vagrantfile vendored
View file

@ -38,7 +38,7 @@ Vagrant.configure(2) do |config|
#vbox.customize ["storageattach", :id, "--storagectl", "SCSI", "--port", 1, "--nonrotational", "on"]
# Set to true, if you intent to use a GUI
vbox.gui = false
vbox.gui = true
end
config.vm.define "jbdev" do |dev|
@ -54,11 +54,26 @@ Vagrant.configure(2) do |config|
# https://www.virtualbox.org/manual/ch06.html#network_nat_service
dev.vm.network :private_network, ip: "192.168.6.65"
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 = "provisioning/playbook.yml"
# ansible.inventory_path = "provisioning/inventory"
# 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
dev.vm.provision "ansible_local" do |ansible|
#ansible.verbose = "vvv"
ansible.compatibility_mode = "2.0"
ansible.install_mode = "pip"
ansible.version = "2.10.3"
ansible.playbook = "provisioning/playbook.yml"
ansible.inventory_path = "provisioning/inventory"
#ansible.inventory_path = "provisioning/inventory"
ansible.become = true
end
end

View file

@ -1,4 +1,4 @@
- hosts: jbdev
- hosts: all
gather_facts: yes
become: yes