
    Vhu                         d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ d dlmZ d dlmZmZ d	 Zd
 Zd Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functiona  
module: eos_banner
author: Peter Sprygada (@privateip)
short_description: Manage multiline banners on Arista EOS devices
description:
- This will configure both login and motd banners on remote devices running Arista
  EOS.  It allows playbooks to add or remote banner text from the active running configuration.
version_added: 1.0.0
notes:
- Tested against Arista EOS 4.24.6F
options:
  banner:
    description:
    - Specifies which banner that should be configured on the remote device.
    required: true
    choices:
    - login
    - motd
    type: str
  text:
    description:
    - The banner text that should be present in the remote device running configuration.  This
      argument accepts a multiline string. Requires I(state=present).
    type: str
  state:
    description:
    - Specifies whether or not the configuration is present in the current devices
      active running configuration.
    default: present
    type: str
    choices:
    - present
    - absent
a  
- name: configure the login banner
  arista.eos.eos_banner:
    banner: login
    text: |
      this is my login banner
      that contains a multiline
      string
    state: present

- name: remove the motd banner
  arista.eos.eos_banner:
    banner: motd
    state: absent
a  
commands:
  description: The list of configuration mode commands to send to the device
  returned: always
  type: list
  sample:
    - banner login
    - this is my login banner
    - that contains a multiline
    - string
    - EOF
session_name:
  description: The EOS config session name used to load the configuration
  returned: if changes
  type: str
  sample: ansible_1479315771
)to_text)AnsibleModule)string_types)load_configrun_commandsc                    t               }| \  }}|j                  d   }|dk(  r|j                  d      rt        |d   t              r#|j                  d|j                  d   z         |S |d   j                  d      s|d   j                  d      r#|j                  dd|j                  d   z  i       |S |d	k(  rt        |d   t              rp|d   |d   k7  rc|j                  d
|j                  d   z         |j                  |d   j                         j                  d             |j                  d       |S |d   j                  d      xs |d   j                  d      }|r|j                         }t        |d         |k7  s|s6|j                  d
|j                  d   z  |d   j                  d      d       |S )Nstateabsenttextzno banner %sbannerloginBannermotdcmdpresentz	banner %s
EOF)r   input)
listparamsget
isinstancer   appendextendstripsplitr   )updatesmodulecommandswanthaver   	have_texts          i/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/arista/eos/plugins/modules/eos_banner.pymap_obj_to_commandsr&   f   s   vHJD$MM'"ETXXf-d6lL1OONV]]8-DDE6 O5 &\m,V0@0@0HOOUNV]]85L$LMN2 O/ 
)	d6lL1F|tF|+fmmH.E EFV 2 2 4 : :4 @A&$ O! V((7 4<;K;K<I %OO-	tF|$	1 *V]]8-DD!%f!3!3D!9 O    c                     t        | d| j                  d   z  g      }| j                  d   dd}|r|d   |d<   d|d<   |S )	Nzshow banner %sr   r   )r   r   r   r   r   r   )r
   r   )r    outputobjs      r%   map_config_to_objr+      sQ    &#3fmmH6M#M"NOF]]8,x
@CQiF GJr'   c                     | j                   d   }|rt        |      j                         }| j                   d   || j                   d   dS )Nr   r   r   r   r   r   )r   r   r   )r    r   s     r%   map_params_to_objr.      sL    == Dt}""$ --)w' r'   c            	         t        t        dddg      t               t        dddg            } d	g}t        | |d
      }t               }ddi}|r||d<   t        |      }t	        |      }t        ||f|      }||d<   |rg|j                   }t        |||      }	|	j                  d      r"|j                  rd|	j                  d      i|d<   |	j                  d      |d<   d|d<    |j                  di | y)z%main entry point for module executionTloginr   )requiredchoicesr   r   )defaultr2   r-   )r   r   )r   )argument_specrequired_ifsupports_check_modechangedFwarningsr!   )commitdiffpreparedsessionsession_nameN )dictr   r   r.   r+   r&   
check_moder	   r   _diff	exit_json)
r4   r5   r    r8   resultr"   r#   r!   r9   responses
             r%   mainrE      s   TGV+<=V9y(.CDM 33K# F vHF%zV$DV$D"D$<8H!F:&&&vx?<<FLL((,,v*>?F6N!)i!8~ yFvr'   __main__N)
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils._textr   ansible.module_utils.basicr   ansible.module_utils.sixr   Cansible_collections.arista.eos.plugins.module_utils.network.eos.eosr	   r
   r&   r+   r.   rE   __name__r>   r'   r%   <module>rR      se   $ A @ !F 
" / 4 1"J	#L zF r'   