diff --git a/.local/bin/ansible-become-password b/.local/bin/ansible-become-password new file mode 100755 index 0000000..70f2650 --- /dev/null +++ b/.local/bin/ansible-become-password @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# vim:ft=ruby + +@var_name = "ANSIBLE_BECOME_PASSWORD" +require_relative "../lib/get-env-var" diff --git a/.local/bin/ansible-vault-password b/.local/bin/ansible-vault-password new file mode 100755 index 0000000..692a03c --- /dev/null +++ b/.local/bin/ansible-vault-password @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# vim:ft=ruby + +@var_name = "ANSIBLE_VAULT_PASSWORD" +require_relative "../lib/get-env-var" diff --git a/.local/lib/get-env-var.rb b/.local/lib/get-env-var.rb new file mode 100644 index 0000000..466daa2 --- /dev/null +++ b/.local/lib/get-env-var.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +if !defined?(@var_name) + $stderr.puts "`var_name` is undefined" + exit 2 +end + +if !ENV.key?(@var_name) + $stderr.puts "#{@var_name} is not set" + exit 1 +end + +printf "%s", ENV[@var_name]