Add ENV helper
This commit is contained in:
parent
dec408e377
commit
f5d94f49ec
7
.local/bin/ansible-become-password
Executable file
7
.local/bin/ansible-become-password
Executable file
@ -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"
|
7
.local/bin/ansible-vault-password
Executable file
7
.local/bin/ansible-vault-password
Executable file
@ -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"
|
13
.local/lib/get-env-var.rb
Normal file
13
.local/lib/get-env-var.rb
Normal file
@ -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]
|
Loading…
Reference in New Issue
Block a user