�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l m Z d d l m Z m Z d d l m Z m
Z
d d
l Z d � Z d � Z
d � Z d � Z d � Z e d k r� e � n d
S( s 1.1t metadata_versiont previewt statust networkt supported_bys�
---
module: nxos_banner
version_added: "2.4"
author: "Trishna Guha (@trishnaguha)"
short_description: Manage multiline banners on Cisco NXOS devices
description:
- This will configure both exec and motd banners on remote devices
running Cisco NXOS. It allows playbooks to add or remote
banner text from the active running configuration.
options:
banner:
description:
- Specifies which banner that should be
configured on the remote device.
required: true
choices: ['exec', 'motd']
text:
description:
- The banner text that should be
present in the remote device running configuration. This argument
accepts a multiline string, with no empty lines. Requires I(state=present).
state:
description:
- Specifies whether or not the configuration is present in the current
devices active running configuration.
default: present
choices: ['present', 'absent']
extends_documentation_fragment: nxos
s�
- name: configure the exec banner
nxos_banner:
banner: exec
text: |
this is my exec banner
that contains a multiline
string
state: present
- name: remove the motd banner
nxos_banner:
banner: motd
state: absent
- name: Configure banner from file
nxos_banner:
banner: motd
text: "{{ lookup('file', './config_partial/raw_banner.cfg') }}"
state: present
s�
commands:
description: The list of configuration mode commands to send to the device
returned: always
type: list
sample:
- banner exec
- this is my exec banner
- that contains a multiline
- string
i����( t
AnsibleModule( t load_configt run_commands( t nxos_argument_spect
check_argsNc C s0 d } i | d 6| d 6g } t | | � } | S( Nt textt commandt output( R ( t moduleR t formatt cmdsR ( ( sL /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_banner.pyt execute_show_command_ s
c C s� t � } | j d } d } | d k r� | j d � r� | j d � d k pd t j | | j d � � r� | j d | j d � q� n[ | d k r� | j d � | j d � k r� d | j d | d j � f } | j | � n | S(
Nt states
Nexus.*Switcht absentR
s User Access Verifications no banner %st bannert presents banner %s @
%s
@( t listt paramst gett ret matcht appendt strip( t wantt haveR
t commandsR t platform_regext
banner_cmd( ( sL /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_banner.pyt map_obj_to_commandsi s
@*!c C s d | j d } t | | � d } d | k rN | j d d | j d � n t | t � r� t | j � � } | g k r� | d } n d } t | t � r� t | j � � } | g k r� | d } q� d } q� n | j � } i | j d d 6d d 6} | r| | d
<d | d <n | S( Ns show banner %sR i s Invalid commandt msgsT banner: %s may not be supported on this platform. Possible values are : exec | motdt R R R
R ( R R t fail_jsont
isinstancet dictR t valuest rstrip( R
R R t obj( ( sL /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_banner.pyt map_config_to_objy s(
c C sO | j d } | r( t | � j � } n i | j d d 6| d 6| j d d 6S( NR
R R ( R t strR ( R
R
( ( sL /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_banner.pyt map_params_to_obj� s
c C s� t d t d t d d d g � d t � d t d d d d d
g � � } | j t � d d d f g } t d | d | d
t � } t � } t | | � i t d 6} | r� | | d <n t | � } t | � } t
| | | � } | | d <| r�| j s}t | | t � } | r}xd | D]Y } | rt
| t � rB| d }
n | }
d |
k s`d |
k rst | | � qsqqWq}n t | d <n | j | � d S( s+ main entry point for module execution
R t requiredt choicest exect motdR
R t defaultR R t
argument_spect required_ift supports_check_modet changedt warningsR t clierrors more than 40 liness buffer overflowedN( R
( R&