�
�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 d d l m Z d d
l m
Z
m Z d d l 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_bysf
---
module: ios_banner
version_added: "2.3"
author: "Ricardo Carrillo Cruz (@rcarrillocruz)"
short_description: Manage multiline banners on Cisco IOS devices
description:
- This will configure both login and motd banners on remote devices
running Cisco IOS. It allows playbooks to add or remote
banner text from the active running configuration.
extends_documentation_fragment: ios
notes:
- Tested against IOS 15.6
options:
banner:
description:
- Specifies which banner should be configured on the remote device.
In Ansible 2.4 and earlier only I(login) and I(motd) were supported.
required: true
choices: ['login', 'motd', 'exec', 'incoming', 'slip-ppp']
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']
s�
- name: configure the login banner
ios_banner:
banner: login
text: |
this is my login banner
that contains a multiline
string
state: present
- name: remove the motd banner
ios_banner:
banner: motd
state: absent
- name: Configure banner from file
ios_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 login
- this is my login banner
- that contains a multiline
- string
i����( t
AnsibleModule( t exec_command( t load_config( t ios_argument_spect
check_argsNc C s� t � } | \ } } | j d } | d k re d | j � k re | d re | j d | j d � n{ | d k r� | d r� | d | j d � k r� d | j d } | d 7} | | d j � 7} | d 7} | j | � q� n | S(
Nt statet absentt texts no banner %st bannert presents banner %ss @
s
@( t listt paramst keyst appendt gett strip( t updatest modulet commandst wantt haveR
t
banner_cmd( ( sJ /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_banner.pyt map_obj_to_commandsb s
(#
c C s� t | d | j d � \ } } } | d k r8 | } nY t | d | j d � \ } } } | r� t j d | t j � j d � j � } n d } i | j d d 6d d 6} | r� | | d <d
| d <n | S( Ns show banner %sR
i s% show running-config | begin banner %ss \^C(.*?)\^Ci R R
R R ( R R t ret searcht St groupR t None( R t rct outt errt outputt obj( ( sJ /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_banner.pyt map_config_to_obju 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 ( ( sJ /usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_banner.pyt map_params_to_obj� s
c C s5 t d t d t d d d 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
| | f | � } | | d <| r$| j st | | � n t | d <n | j
| � d S( s+ main entry point for module execution
R
t requiredt choicest logint motdt exect incomings slip-pppR R
t defaultR R t
argument_spect required_ift supports_check_modet changedt warningsR N( R ( t dictt Truet updateR R R R t FalseR( R&