Skip to content

Commit

Permalink
Add vault view command (#707)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <berendt@osism.tech>
  • Loading branch information
berendt authored Nov 29, 2023
1 parent 5a31752 commit f210602
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions osism/commands/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# It's not ready in that form yet.

import os
import subprocess

from cliff.command import Command
from cryptography.fernet import Fernet
Expand Down Expand Up @@ -43,3 +44,18 @@ def get_parser(self, prog_name):

def take_action(self, parsed_args):
redis.delete("ansible_vault_password")


class View(Command):
def get_parser(self, prog_name):
parser = super(View, self).get_parser(prog_name)
parser.add_argument(
"path", nargs="?", type=str, help="Path to the secret.yml file"
)
return parser

def take_action(self, parsed_args):
path = parsed_args.path
if not os.path.isabs(path):
path = os.path.join("/opt/configuration", path)
subprocess.call(f"/usr/local/bin/ansible-vault view {path}", shell=True)
7 changes: 7 additions & 0 deletions releasenotes/notes/vault-view-command-09887cfd02679002.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
features:
- |
With `vault view` it is possible to view an encrypted file
inside the configuration repository. It is possible to use
absolute (`/opt/configuration/environments/..`) and relative
(`environments/..`) paths.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ osism.commands:
validate = osism.commands.validate:Run
vault password set = osism.commands.vault:SetPassword
vault password unset = osism.commands.vault:UnsetPassword
vault view = osism.commands.vault:View
wait = osism.commands.wait:Run
worker = osism.commands.worker:Run

0 comments on commit f210602

Please sign in to comment.