Validate EXAMPLES as YAML

This commit is contained in:
Matt Martz 2017-02-07 15:39:24 -06:00 committed by Toshio Kuratomi
commit 7c00346714
112 changed files with 441 additions and 381 deletions

View file

@ -102,6 +102,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -111,6 +112,7 @@ vars:
authorize: yes
auth_pass: cisco
---
- asa_acl:
lines:
- access-list ACL-ANSIBLE extended permit tcp any any eq 82
@ -127,7 +129,7 @@ vars:
lines:
- access-list ACL-OUTSIDE extended permit tcp any any eq www
- access-list ACL-OUTSIDE extended permit tcp any any eq https
context: customer_a
context: customer_a
provider: "{{ cli }}"
"""

View file

@ -84,6 +84,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -93,7 +94,7 @@ vars:
auth_pass: cisco
transport: cli
---
- asa_command:
commands:
- show version

View file

@ -172,6 +172,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -181,6 +182,7 @@ vars:
auth_pass: cisco
transport: cli
---
- asa_config:
lines:
- network-object host 10.80.30.18

View file

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# Ansible module to manage Big Monitoring Fabric service chains
# (c) 2016, Ted Elhourani <ted@bigswitch.com>
# (c) 2016, Ted Elhourani <ted@bigswitch.com>,
#
# This file is part of Ansible
#
@ -59,11 +59,11 @@ options:
EXAMPLES = '''
- name: bigmon inline service chain
bigmon_chain:
name: MyChain
controller: '{{ inventory_hostname }}'
state: present
validate_certs: false
bigmon_chain:
name: MyChain
controller: '{{ inventory_hostname }}'
state: present
validate_certs: false
'''

View file

@ -84,13 +84,13 @@ options:
EXAMPLES = '''
- name: policy to aggregate filter and deliver data center (DC) 1 traffic
bigmon_policy:
name: policy1
policy_description: DC 1 traffic policy
action: drop
controller: '{{ inventory_hostname }}'
state: present
validate_certs: false
bigmon_policy:
name: policy1
policy_description: DC 1 traffic policy
action: drop
controller: '{{ inventory_hostname }}'
state: present
validate_certs: false
'''
RETURN = '''

View file

@ -84,6 +84,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -91,6 +92,7 @@ vars:
password: admin
transport: cli
---
- name: run display version on remote devices
ce_command:
commands: display version

View file

@ -186,6 +186,7 @@ EXAMPLES = '''
# In vars file
# ============
---
cl_bonds:
bond0:
alias_name: uplink to isp

View file

@ -140,6 +140,7 @@ EXAMPLES = '''
# In vars file
# ============
---
cl_bridge:
br0:
alias_name: 'vlan aware bridge'

View file

@ -146,8 +146,8 @@ EXAMPLES = '''
# define cl_interfaces once in tasks
# then write interfaces in variables file
# with just the options you want.
- name: Create interfaces
cl_interface:
- name: Create interfaces
cl_interface:
name: '{{ item.key }}'
ipv4: '{{ item.value.ipv4 | default(omit) }}'
ipv6: '{{ item.value.ipv6 | default(omit) }}'
@ -165,11 +165,12 @@ EXAMPLES = '''
mstpctl_portnetwork: "{{ item.value.mstpctl_portnetwork | default('no') }}"
mstpctl_portadminedge: "{{ item.value.mstpctl_portadminedge | default('no') }}"
mstpctl_bpduguard: "{{ item.value.mstpctl_bpduguard | default('no') }}"
with_dict: '{{ cl_interfaces }}'
notify: reload networking
with_dict: '{{ cl_interfaces }}'
notify: reload networking
# In vars file
# ============
---
cl_interfaces:
swp1:
alias_name: uplink to isp

View file

@ -49,7 +49,7 @@ options:
'''
EXAMPLES = '''
Example playbook entries using the cl_interface_policy module.
# Example playbook entries using the cl_interface_policy module.
- name: shows types of interface ranges supported
cl_interface_policy:

View file

@ -78,7 +78,7 @@ EXAMPLES = '''
dest: /etc/network/interfaces
notify: restart networking
handlers:
handlers:
- name: restart switchd
service:
name: switchd
@ -89,10 +89,7 @@ EXAMPLES = '''
state: reloaded
# Force all switches to accept a new license. Typically not needed
ansible -m cl_license -a "src='http://10.1.1.1/new_lic' force=yes" -u root all
----
# ansible -m cl_license -a "src='http://10.1.1.1/new_lic' force=yes" -u root all
'''
RETURN = '''

View file

@ -97,7 +97,7 @@ tasks:
provider: "{{ cli }}"
- name: run multiple commands on remote nodes
dellos10_command:
dellos10_command:
commands:
- show version
- show interface

View file

@ -87,20 +87,20 @@ tasks:
- name: run show version on remote devices
dellos6_command:
commands: show version
provider "{{ cli }}"
provider: "{{ cli }}"
- name: run show version and check to see if output contains Dell
dellos6_command:
commands: show version
wait_for: result[0] contains Dell
provider "{{ cli }}"
provider: "{{ cli }}"
- name: run multiple commands on remote nodes
dellos6_command:
commands:
- show version
- show interfaces
provider "{{ cli }}"
provider: "{{ cli }}"
- name: run multiple commands and evaluate the output
dellos6_command:
@ -110,7 +110,7 @@ tasks:
wait_for:
- result[0] contains Dell
- result[1] contains Access
provider "{{ cli }}"
provider: "{{ cli }}"
"""
RETURN = """

View file

@ -136,7 +136,7 @@ EXAMPLES = '''
delegate_to: localhost
# create a my.com CNAME record to example.com
- dnsimple
- dnsimple:
domain: my.com
record: ''
type: CNAME

View file

@ -94,7 +94,7 @@ EXAMPLES = """
wait_for: result[0] contains Arista
- name: run multiple commands on remote nodes
eos_command:
eos_command:
commands:
- show version
- show interfaces

View file

@ -104,7 +104,7 @@ EXAMPLES = """
lookup_source: Management1
- name: configure DNS lookup sources with VRF support
eos_system:
eos_system:
lookup_source:
- interface: Management1
vrf: mgmt

View file

@ -199,7 +199,7 @@ EXAMPLES = '''
state: "present"
name: "my-pool"
partition: "Common"
host: "{{ ansible_default_ipv4["address"] }}"
host: "{{ ansible_default_ipv4['address'] }}"
port: 80
- name: Remove pool member from pool
@ -210,7 +210,7 @@ EXAMPLES = '''
state: "absent"
name: "my-pool"
partition: "Common"
host: "{{ ansible_default_ipv4["address"] }}"
host: "{{ ansible_default_ipv4['address'] }}"
port: 80
- name: Delete pool

View file

@ -132,7 +132,7 @@ EXAMPLES = '''
state: "present"
pool: "my-pool"
partition: "Common"
host: "{{ ansible_default_ipv4["address"] }}"
host: "{{ ansible_default_ipv4['address'] }}"
port: 80
description: "web server"
connection_limit: 100
@ -148,7 +148,7 @@ EXAMPLES = '''
state: "present"
pool: "my-pool"
partition: "Common"
host: "{{ ansible_default_ipv4["address"] }}"
host: "{{ ansible_default_ipv4['address'] }}"
port: 80
ratio: 1
description: "nginx server"
@ -162,7 +162,7 @@ EXAMPLES = '''
state: "absent"
pool: "my-pool"
partition: "Common"
host: "{{ ansible_default_ipv4["address"] }}"
host: "{{ ansible_default_ipv4['address'] }}"
port: 80
delegate_to: localhost
@ -190,7 +190,7 @@ EXAMPLES = '''
monitor_state: "disabled"
pool: "my-pool"
partition: "Common"
host: "{{ ansible_default_ipv4["address"] }}"
host: "{{ ansible_default_ipv4['address'] }}"
port: 80
delegate_to: localhost
'''

View file

@ -49,6 +49,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -56,6 +57,7 @@ vars:
password: cisco
transport: cli
---
# Collect all facts from the device
- ios_facts:
gather_subset: all

View file

@ -95,7 +95,7 @@ tasks:
wait_for: result[0] contains IOS-XR
- name: run multiple commands on remote nodes
iosxr_command:
iosxr_command:
commands:
- show version
- show interfaces

View file

@ -99,10 +99,12 @@ EXAMPLES = """
comment: update system config
- name: replace config hierarchy
junos_template:
src: config.j2
action: replace
- name: overwrite the config
junos_template:
src: config.j2
action: overwrite
"""

View file

@ -110,12 +110,14 @@ notes:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
netconf:
host: "{{ inventory_hostname }}"
username: ansible
password: Ansible
---
- name: run a set of commands
junos_command:
commands: ['show version', 'show ip route']

View file

@ -146,12 +146,14 @@ notes:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
netconf:
host: "{{ inventory_hostname }}"
username: ansible
password: Ansible
---
- name: load configure file into device
junos_config:
src: srx.cfg

View file

@ -58,6 +58,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -65,6 +66,7 @@ vars:
password: Ansible
transport: cli
---
- name: enable netconf service on port 830
junos_netconf:
listens_on: 830

View file

@ -361,26 +361,26 @@ EXAMPLES='''
- '{{ nmcli_team_slave }}'
###### Working with all cloud nodes - Bonding
- name: try nmcli add bond - conn_name only & ip4 gw4 mode
nmcli:
type: bond
conn_name: '{{ item.conn_name }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
mode: '{{ item.mode }}'
state: present
with_items:
- '{{ nmcli_bond }}'
- name: try nmcli add bond - conn_name only & ip4 gw4 mode
nmcli:
type: bond
conn_name: '{{ item.conn_name }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
mode: '{{ item.mode }}'
state: present
with_items:
- '{{ nmcli_bond }}'
- name: try nmcli add bond-slave
nmcli:
type: bond-slave
conn_name: '{{ item.conn_name }}'
ifname: '{{ item.ifname }}'
master: '{{ item.master }}'
state: present
with_items:
- '{{ nmcli_bond_slave }}'
- name: try nmcli add bond-slave
nmcli:
type: bond-slave
conn_name: '{{ item.conn_name }}'
ifname: '{{ item.ifname }}'
master: '{{ item.master }}'
state: present
with_items:
- '{{ nmcli_bond_slave }}'
##### Working with all cloud nodes - Ethernet
- name: nmcli add Ethernet - conn_name only & ip4 gw4
@ -394,8 +394,6 @@ EXAMPLES='''
- '{{ nmcli_ethernet }}'
## playbook-del.yml example
---
- hosts: openstack-stage
remote_user: root
tasks:

View file

@ -259,8 +259,8 @@ options:
choices: ['present','absent']
'''
EXAMPLES = '''
configure RR client
- nxos_bgp_neighbor_af:
- name: configure RR client
nxos_bgp_neighbor_af:
asn: 65535
neighbor: '3.3.3.3'
afi: ipv4

View file

@ -91,6 +91,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -98,6 +99,7 @@ vars:
password: admin
transport: cli
---
- name: run show version on remote devices
nxos_command:
commands: show version
@ -110,7 +112,7 @@ vars:
provider: "{{ cli }}"
- name: run multiple commands on remote nodes
nxos_command:
nxos_command:
commands:
- show version
- show interfaces

View file

@ -164,6 +164,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -171,6 +172,7 @@ vars:
password: admin
transport: cli
---
- name: configure top level configuration and save it
nxos_config:
lines: hostname {{ inventory_hostname }}

View file

@ -53,6 +53,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -60,6 +61,7 @@ vars:
password: admin
transport: cli
---
- nxos_facts:
gather_subset: all

View file

@ -68,33 +68,33 @@ EXAMPLES = '''
username: "{{ un }}"
password: "{{ pwd }}"
transport: nxapi
rescue:
- name: Wait for device to perform checks
wait_for:
port: 22
state: stopped
timeout: 300
delay: 60
host: "{{ inventory_hostname }}"
- name: Wait for device to come back up
wait_for:
port: 22
state: started
timeout: 300
delay: 60
host: "{{ inventory_hostname }}"
- name: Check installed OS
nxos_command:
commands:
- show version
username: "{{ un }}"
password: "{{ pwd }}"
host: "{{ inventory_hostname }}"
transport: nxapi
register: output
- assert:
that:
- output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I4(1)'
rescue:
- name: Wait for device to perform checks
wait_for:
port: 22
state: stopped
timeout: 300
delay: 60
host: "{{ inventory_hostname }}"
- name: Wait for device to come back up
wait_for:
port: 22
state: started
timeout: 300
delay: 60
host: "{{ inventory_hostname }}"
- name: Check installed OS
nxos_command:
commands:
- show version
username: "{{ un }}"
password: "{{ pwd }}"
host: "{{ inventory_hostname }}"
transport: nxapi
register: output
- assert:
that:
- output['stdout'][0]['kickstart_ver_str'] == '7.0(3)I4(1)'
'''
RETURN = '''

View file

@ -89,48 +89,49 @@ options:
'''
EXAMPLES = '''
- name Ensure an interface is a Layer 3 port and that it has the proper description
- name: Ensure an interface is a Layer 3 port and that it has the proper description
nxos_interface:
interface: Ethernet1/1
description: 'Configured by Ansible'
mode: layer3
host: 68.170.147.165
- name Admin down an interface
- name: Admin down an interface
nxos_interface:
interface: Ethernet2/1
host: 68.170.147.165
admin_state: down
- name Remove all loopback interfaces
- name: Remove all loopback interfaces
nxos_interface:
interface: loopback
state: absent
host: 68.170.147.165
- name Remove all logical interfaces
- name: Remove all logical interfaces
nxos_interface:
interface_type: "{{ item }} "
state: absent
host: "{{ inventory_hostname }}"
with_items:
- loopback
- portchannel
- svi
- nve
- name Admin up all ethernet interfaces
- name: Admin up all ethernet interfaces
nxos_interface:
interface: ethernet
host: 68.170.147.165
admin_state: up
- name Admin down ALL interfaces (physical and logical)
- name: Admin down ALL interfaces (physical and logical)
nxos_interface:
interface: all
host: 68.170.147.165
admin_state: down
'''
RETURN = '''
proposed:
description: k/v pairs of parameters passed into module

View file

@ -76,14 +76,14 @@ options:
EXAMPLES = """
- name: set hostname with file lookup
ops_template:
ops_template:
src: ./hostname.json
backup: yes
remote_user: admin
become: yes
- name: set hostname with var
ops_template:
ops_template:
src: "{{ config }}"
remote_user: admin
become: yes

View file

@ -85,6 +85,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -92,6 +93,7 @@ vars:
password: netop
transport: cli
---
- ops_command:
commands:
- show version

View file

@ -139,12 +139,14 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
username: netop
password: netop
---
- name: configure hostname over cli
ops_config:
lines:

View file

@ -73,6 +73,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -85,6 +86,7 @@ vars:
password: netop
transport: rest
---
- ops_facts:
gather_subset: all
provider: "{{ rest }}"

View file

@ -85,6 +85,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -92,6 +93,7 @@ vars:
password: admin
transport: cli
---
tasks:
- name: run show version on remote devices
sros_command:
@ -105,7 +107,7 @@ tasks:
provider: "{{ cli }}"
- name: run multiple commands on remote nodes
sros_command:
sros_command:
commands:
- show version
- show port detail

View file

@ -160,6 +160,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -167,19 +168,20 @@ vars:
password: admin
transport: cli
---
- name: enable rollback location
sros_config:
sros_config:
lines: configure system rollback rollback-location "cf3:/ansible"
provider: "{{ cli }}"
- name: set system name to {{ inventory_hostname }} using one line
sros_config:
sros_config:
lines:
- configure system name "{{ inventory_hostname }}"
provider: "{{ cli }}"
- name: set system name to {{ inventory_hostname }} using parents
sros_config:
sros_config:
lines:
- 'name "{{ inventory_hostname }}"'
parents:
@ -189,7 +191,7 @@ vars:
backup: yes
- name: load config from file
sros_config:
sros_config:
src: "{{ inventory_hostname }}.cfg"
provider: "{{ cli }}"
save: yes

View file

@ -79,6 +79,7 @@ options:
EXAMPLES = """
# Note: examples below use the following provider dict to handle
# transport and authentication to the node.
---
vars:
cli:
host: "{{ inventory_hostname }}"
@ -86,6 +87,7 @@ vars:
password: admin
transport: cli
---
- name: configure rollback location
sros_rollback:
rollback_location: "cb3:/ansible"