1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #16733 from privateip/plugin-action-net-config

removes methods to write to dest from net_config
This commit is contained in:
Peter Sprygada 2016-07-15 18:03:13 -04:00 committed by GitHub
commit 134d70e7b9

View file

@ -49,13 +49,8 @@ class ActionModule(ActionBase):
# NOTE: If there is a parameter error, _backup key may not be in results.
self._write_backup(task_vars['inventory_hostname'], result['__backup__'])
if self._task.args.get('dest') and result.get('__config__'):
self._write_dest(self._task.args['dest'], result['__config__'],
append=self._task.args['append'])
for key in ['__config__', '__backup__']:
if key in result:
del result[key]
if '__backup__' in result:
del result['__backup__']
return result
@ -75,18 +70,6 @@ class ActionModule(ActionBase):
filename = '%s/%s_config.%s' % (backup_path, host, tstamp)
open(filename, 'w').write(contents)
def _write_dest(self, path, contents, append=False):
dirpath = os.path.dirname(path)
if not dirpath[0] == '/':
dirpath = self._get_working_path() + dirpath
if not os.path.exists(dirpath):
os.mkdir(dirpath)
if append:
flags = 'a'
else:
flags = 'w'
open(path, flags).write(contents)
def _handle_template(self):
src = self._task.args.get('src')
working_path = self._get_working_path()