class Chef::Knife::VaultRotateAllKeys

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/vault_rotate_all_keys.rb, line 29
def run
  clean_unknown_clients = config[:clean_unknown_clients]
  set_mode(config[:vault_mode])
  rotate_all_keys(clean_unknown_clients)
end

Private Instance Methods

rotate_all_keys(clean_unknown_clients = false) click to toggle source
# File lib/chef/knife/vault_rotate_all_keys.rb, line 37
def rotate_all_keys(clean_unknown_clients = false)
  vaults = Chef::DataBag.list.keys
  vaults.each { |vault| rotate_vault_keys(vault, clean_unknown_clients) }
end
rotate_vault_item_keys(vault, item, clean_unknown_clients) click to toggle source
# File lib/chef/knife/vault_rotate_all_keys.rb, line 55
def rotate_vault_item_keys(vault, item, clean_unknown_clients)
  ui.info "Rotating keys for: #{vault} #{item}"
  ChefVault::Item.load(vault, item).rotate_keys!(clean_unknown_clients)
end
rotate_vault_keys(vault, clean_unknown_clients) click to toggle source
# File lib/chef/knife/vault_rotate_all_keys.rb, line 42
def rotate_vault_keys(vault, clean_unknown_clients)
  vault_items(vault).each do |item|
    rotate_vault_item_keys(vault, item, clean_unknown_clients)
  end
end
vault_items(vault) click to toggle source

Permalink for regex of replacing ‘_keys’ with ”: rubular.com/r/5cA5JNSyLfPSfY

# File lib/chef/knife/vault_rotate_all_keys.rb, line 49
def vault_items(vault)
  Chef::DataBag.load(vault).keys.each_with_object([]) do |key, array|
    array << key.sub(/_keys(?=[^_keys]*$)/, "") if key =~ /.+_keys$/
  end
end