From 3aedc0bca9f1233949082874d93d20df9e7c3565 Mon Sep 17 00:00:00 2001 From: Abhijit Menon-Sen Date: Sat, 22 Aug 2015 19:47:15 +0530 Subject: [PATCH] Don't insist on ansible-vault taking only one filename parameter Apart from ansible-vault create, every vault subcommand is happy to deal with multiple filenames, so we can check that there's at least one, and make create check separately that there aren't any extra. --- lib/ansible/cli/vault.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/cli/vault.py b/lib/ansible/cli/vault.py index 8cf1bf73885..fed44797cfd 100644 --- a/lib/ansible/cli/vault.py +++ b/lib/ansible/cli/vault.py @@ -64,8 +64,8 @@ class VaultCLI(CLI): self.options, self.args = self.parser.parse_args() self.display.verbosity = self.options.verbosity - if len(self.args) == 0 or len(self.args) > 1: - raise AnsibleOptionsError("Vault requires a single filename as a parameter") + if len(self.args) == 0: + raise AnsibleOptionsError("Vault requires at least one filename as a parameter") def run(self): @@ -84,6 +84,9 @@ class VaultCLI(CLI): def execute_create(self): + if len(self.args) > 1: + raise AnsibleOptionsError("ansible-vault create can take only one filename argument") + cipher = getattr(self.options, 'cipher', self.CIPHER) this_editor = VaultEditor(cipher, self.vault_pass, self.args[0]) this_editor.create_file()