Persist PLAYBOOK env between shell sessions

This commit is contained in:
Kris Lamoureux 2021-03-13 02:44:30 -05:00
parent a7d05e7de6
commit cb6b24f1a8
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
2 changed files with 16 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.vagrant .vagrant
.playbook
/*.yml /*.yml
/*.yaml /*.yaml
!moxie.yml !moxie.yml

16
Vagrantfile vendored
View File

@ -1,6 +1,20 @@
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=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| Vagrant.configure("2") do |config|
config.vm.box = "debian/buster64" config.vm.box = "debian/buster64"
config.vm.network "private_network", type: "dhcp" config.vm.network "private_network", type: "dhcp"
@ -24,7 +38,7 @@ Vagrant.configure("2") do |config|
ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles" ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles"
ansible.compatibility_mode = "2.0" ansible.compatibility_mode = "2.0"
ansible.galaxy_role_file = ENV['ANSIBLE_ROLES_PATH'] + "/requirements.yml" ansible.galaxy_role_file = ENV['ANSIBLE_ROLES_PATH'] + "/requirements.yml"
ansible.playbook = "dev/" + ENV["PLAYBOOK"] + ".yml" ansible.playbook = "dev/" + PLAYBOOK + ".yml"
end end
end end