mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Implement eos_banner for EAPI (#22609)
On EAPI, the multi-line commands are expected to be a dict, with key/value pairs 'cmd'/'input' . This change implements that behaviour and fixes the idempotency on EAPI as well. Fixes #22494
This commit is contained in:
parent
38eb388154
commit
604a38cac1
8 changed files with 51 additions and 20 deletions
|
@ -106,9 +106,15 @@ def map_obj_to_commands(updates, module):
|
|||
|
||||
elif state == 'present':
|
||||
if want['text'] and (want['text'] != have.get('text')):
|
||||
commands.append('banner %s' % module.params['banner'])
|
||||
commands.extend(want['text'].strip().split('\n'))
|
||||
commands.append('EOF')
|
||||
if module.params['transport'] == 'cli':
|
||||
commands.append('banner %s' % module.params['banner'])
|
||||
commands.extend(want['text'].strip().split('\n'))
|
||||
commands.append('EOF')
|
||||
else:
|
||||
# For EAPI we need to construct a dict with cmd/input
|
||||
# key/values for the banner
|
||||
commands.append({'cmd': 'banner %s' % module.params['banner'],
|
||||
'input': want['text'].strip('\n')})
|
||||
|
||||
return commands
|
||||
|
||||
|
@ -116,7 +122,12 @@ def map_config_to_obj(module):
|
|||
output = run_commands(module, ['show banner %s' % module.params['banner']])
|
||||
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
||||
if output:
|
||||
obj['text'] = output[0]
|
||||
if module.params['transport'] == 'cli':
|
||||
obj['text'] = output[0]
|
||||
else:
|
||||
# On EAPI we need to extract the banner text from dict key
|
||||
# 'loginBanner'
|
||||
obj['text'] = output[0]['loginBanner'].strip('\n')
|
||||
obj['state'] = 'present'
|
||||
return obj
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue