mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00:00
Merge pull request #6580 from ramondelafuente/fix-vault-editor-call
Changed call to EDITOR to allow for parameters
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
# installs ansible and sets it up to run on cron.
|
# installs ansible and sets it up to run on cron.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@@ -190,8 +191,7 @@ class VaultEditor(object):
|
|||||||
raise errors.AnsibleError("%s exists, please use 'edit' instead" % self.filename)
|
raise errors.AnsibleError("%s exists, please use 'edit' instead" % self.filename)
|
||||||
|
|
||||||
# drop the user into vim on file
|
# drop the user into vim on file
|
||||||
EDITOR = os.environ.get('EDITOR','vim')
|
call(self._editor_shell_command(self.filename))
|
||||||
call([EDITOR, self.filename])
|
|
||||||
tmpdata = self.read_data(self.filename)
|
tmpdata = self.read_data(self.filename)
|
||||||
this_vault = VaultLib(self.password)
|
this_vault = VaultLib(self.password)
|
||||||
this_vault.cipher_name = self.cipher_name
|
this_vault.cipher_name = self.cipher_name
|
||||||
@@ -230,8 +230,7 @@ class VaultEditor(object):
|
|||||||
self.write_data(dec_data, tmp_path)
|
self.write_data(dec_data, tmp_path)
|
||||||
|
|
||||||
# drop the user into vim on the tmp file
|
# drop the user into vim on the tmp file
|
||||||
EDITOR = os.environ.get('EDITOR','vim')
|
call(self._editor_shell_command(tmp_path))
|
||||||
call([EDITOR, tmp_path])
|
|
||||||
new_data = self.read_data(tmp_path)
|
new_data = self.read_data(tmp_path)
|
||||||
|
|
||||||
# create new vault
|
# create new vault
|
||||||
@@ -303,6 +302,13 @@ class VaultEditor(object):
|
|||||||
os.remove(dest)
|
os.remove(dest)
|
||||||
shutil.move(src, dest)
|
shutil.move(src, dest)
|
||||||
|
|
||||||
|
def _editor_shell_command(self, filename):
|
||||||
|
EDITOR = os.environ.get('EDITOR','vim')
|
||||||
|
editor = shlex.split(EDITOR)
|
||||||
|
editor.append(filename)
|
||||||
|
|
||||||
|
return editor
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# CIPHERS #
|
# CIPHERS #
|
||||||
########################################
|
########################################
|
||||||
|
|||||||
Reference in New Issue
Block a user