Commit 3aedc0bc by Abhijit Menon-Sen Committed by Brian Coca

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.
parent f1b8323b
...@@ -64,8 +64,8 @@ class VaultCLI(CLI): ...@@ -64,8 +64,8 @@ class VaultCLI(CLI):
self.options, self.args = self.parser.parse_args() self.options, self.args = self.parser.parse_args()
self.display.verbosity = self.options.verbosity self.display.verbosity = self.options.verbosity
if len(self.args) == 0 or len(self.args) > 1: if len(self.args) == 0:
raise AnsibleOptionsError("Vault requires a single filename as a parameter") raise AnsibleOptionsError("Vault requires at least one filename as a parameter")
def run(self): def run(self):
...@@ -84,6 +84,9 @@ class VaultCLI(CLI): ...@@ -84,6 +84,9 @@ class VaultCLI(CLI):
def execute_create(self): 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) cipher = getattr(self.options, 'cipher', self.CIPHER)
this_editor = VaultEditor(cipher, self.vault_pass, self.args[0]) this_editor = VaultEditor(cipher, self.vault_pass, self.args[0])
this_editor.create_file() this_editor.create_file()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment