From cb6b24f1a85507381cf65acf02b1291484a1303d Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Sat, 13 Mar 2021 02:44:30 -0500 Subject: [PATCH] Persist PLAYBOOK env between shell sessions --- .gitignore | 1 + Vagrantfile | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d2f1c73..cc3b44d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .vagrant +.playbook /*.yml /*.yaml !moxie.yml diff --git a/Vagrantfile b/Vagrantfile index e4d8b66..1bb9dd4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,20 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +PLAYBOOK=ENV["PLAYBOOK"] + +if !PLAYBOOK + if File.exist?('.playbook') + PLAYBOOK = IO.read('.playbook').split("\n")[0] + end + + if !PLAYBOOK || PLAYBOOK.empty? + PLAYBOOK = "\nERROR: Set env PLAYBOOK" + end +else + File.write(".playbook", PLAYBOOK) +end + Vagrant.configure("2") do |config| config.vm.box = "debian/buster64" config.vm.network "private_network", type: "dhcp" @@ -24,7 +38,7 @@ Vagrant.configure("2") do |config| ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles" ansible.compatibility_mode = "2.0" ansible.galaxy_role_file = ENV['ANSIBLE_ROLES_PATH'] + "/requirements.yml" - ansible.playbook = "dev/" + ENV["PLAYBOOK"] + ".yml" + ansible.playbook = "dev/" + PLAYBOOK + ".yml" end end