Class: VagrantPlugins::TrellisSequel::Vault
- Inherits:
-
Object
- Object
- VagrantPlugins::TrellisSequel::Vault
- Defined in:
- lib/vagrant_plugins/trellis_sequel/vault.rb
Class Method Summary collapse
Instance Method Summary collapse
- #database_for(site: nil, **_) ⇒ Object
-
#initialize(path:, password:) ⇒ Vault
constructor
A new instance of Vault.
Constructor Details
#initialize(path:, password:) ⇒ Vault
Returns a new instance of Vault.
21 22 23 24 |
# File 'lib/vagrant_plugins/trellis_sequel/vault.rb', line 21 def initialize(path:, password:) @path = path @password = password end |
Class Method Details
.build(machine_root_path:, vault_pass: nil, vault_password_file: nil, **_) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vagrant_plugins/trellis_sequel/vault.rb', line 8 def self.build(machine_root_path:, vault_pass: nil, vault_password_file: nil, **_) vault_path = File.join(machine_root_path, 'group_vars', 'development', 'vault.yml') if ::Ansible::Vault.encrypted?(vault_path) vault_pass ||= VaultPass.read_from_file( file_path: vault_password_file, machine_root_path: machine_root_path ) end Vault.new(path: vault_path, password: vault_pass) end |
Instance Method Details
#database_for(site: nil, **_) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant_plugins/trellis_sequel/vault.rb', line 26 def database_for(site: nil, **_) site ||= first_wordpress_site raise "DB password not found for #{site}" unless password_exist_for?(site) { name: db_name_for(site), user: db_user_for(site), password: db_password_for(site) } end |