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

removes methods to write to dest from net_config
pull/16278/merge
Peter Sprygada 8 years ago committed by GitHub
commit 134d70e7b9

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

Loading…
Cancel
Save