diff --git a/osism/commands/vault.py b/osism/commands/vault.py index fc3f99bb..7cb8d331 100644 --- a/osism/commands/vault.py +++ b/osism/commands/vault.py @@ -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 @@ -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) diff --git a/releasenotes/notes/vault-view-command-09887cfd02679002.yaml b/releasenotes/notes/vault-view-command-09887cfd02679002.yaml new file mode 100644 index 00000000..e53475d2 --- /dev/null +++ b/releasenotes/notes/vault-view-command-09887cfd02679002.yaml @@ -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. diff --git a/setup.cfg b/setup.cfg index 61026dd5..1e833059 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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