From 013722d974fb9cb28023cdb410dfe5053e587f14 Mon Sep 17 00:00:00 2001 From: Fabio Alessandro Locati Date: Fri, 9 Dec 2016 11:00:34 +0000 Subject: [PATCH] Inline attays (#19061) --- .../modules/network/cumulus/cl_bond.py | 28 ++++---- .../modules/network/cumulus/cl_img_install.py | 6 +- .../modules/network/cumulus/cl_interface.py | 67 +++++++++---------- .../modules/network/cumulus/cl_ports.py | 35 +++++----- 4 files changed, 69 insertions(+), 67 deletions(-) diff --git a/lib/ansible/modules/network/cumulus/cl_bond.py b/lib/ansible/modules/network/cumulus/cl_bond.py index baf9b0fe844..43952b4cb7b 100644 --- a/lib/ansible/modules/network/cumulus/cl_bond.py +++ b/lib/ansible/modules/network/cumulus/cl_bond.py @@ -152,16 +152,17 @@ EXAMPLES = ''' # configure a bond interface with IP address - cl_bond: name: bond0 - slaves: "swp4-5" + slaves: + - swp4-5 ipv4: 10.1.1.1/24 - notify: reload networking # configure bond as a dual-connected clag bond - cl_bond: name: bond1 - slaves: "swp1s0 swp2s0" + slaves: + - swp1s0 + - swp2s0 clag_id: 1 - notify: reload networking # define cl_bond once in tasks file # then write interface config in variables file @@ -182,18 +183,21 @@ EXAMPLES = ''' mstpctl_portadminedge: "{{ item.value.mstpctl_portadminedge|default('no') }}" mstpctl_bpduguard: "{{ item.value.mstpctl_bpduguard|default('no') }}" with_dict: "{{ cl_bonds }}" - notify: reload networking # In vars file # ============ cl_bonds: - bond0: - alias_name: 'uplink to isp' - slaves: ['swp1', 'swp3'] - ipv4: '10.1.1.1/24' - bond2: - vids: [1, 50] - clag_id: 1 + bond0: + alias_name: uplink to isp + slaves: + - swp1 + - swp3 + ipv4: 10.1.1.1/24' + bond2: + vids: + - 1 + - 50 + clag_id: 1 ''' RETURN = ''' diff --git a/lib/ansible/modules/network/cumulus/cl_img_install.py b/lib/ansible/modules/network/cumulus/cl_img_install.py index 26fe8857b6f..6daaaa248cc 100644 --- a/lib/ansible/modules/network/cumulus/cl_img_install.py +++ b/lib/ansible/modules/network/cumulus/cl_img_install.py @@ -59,10 +59,7 @@ requirements: ["Cumulus Linux OS"] ''' EXAMPLES = ''' -Example playbook entries using the cl_img_install module - ## Download and install the image from a webserver. - - name: Install image using using http url. Switch slots so the subsequent will load the new version cl_img_install: version: 2.0.1 @@ -83,7 +80,6 @@ Example playbook entries using the cl_img_install module cl_img_install: src: /root/CumulusLinux-2.0.1.bin - ## If the image name has been changed from the original name, use the `version` option ## to inform the module exactly what code version is been installed @@ -92,7 +88,7 @@ Example playbook entries using the cl_img_install module src: ftp://CumulusLinux-2.0.1.bin dest: /root/image.bin -- name: install image and switch slots. only reboot needed +- name: install image and switch slots. Only reboot needed cl_img_install: version: 2.0.1 src: /root/image.bin diff --git a/lib/ansible/modules/network/cumulus/cl_interface.py b/lib/ansible/modules/network/cumulus/cl_interface.py index c8262b0710e..9ef22f880e7 100644 --- a/lib/ansible/modules/network/cumulus/cl_interface.py +++ b/lib/ansible/modules/network/cumulus/cl_interface.py @@ -139,7 +139,7 @@ EXAMPLES = ''' - name: Configure subinterface with an IP cl_interface: name: bond0.100 - alias_name: 'my bond' + alias_name: my bond ipv4: 10.1.1.1/24 notify: reload networking @@ -148,50 +148,49 @@ EXAMPLES = ''' # with just the options you want. - name: Create interfaces cl_interface: - name: "{{ item.key }}" - ipv4: "{{ item.value.ipv4 | default(omit) }}" - ipv6: "{{ item.value.ipv6 | default(omit) }}" - alias_name: "{{ item.value.alias_name | default(omit) }}" - addr_method: "{{ item.value.addr_method | default(omit) }}" - speed: "{{ item.value.link_speed | default(omit) }}" - mtu: "{{ item.value.mtu | default(omit) }}" - clagd_enable: "{{ item.value.clagd_enable | default(omit) }}" - clagd_peer_ip: "{{ item.value.clagd_peer_ip | default(omit) }}" - clagd_sys_mac: "{{ item.value.clagd_sys_mac | default(omit) }}" - clagd_priority: "{{ item.value.clagd_priority | default(omit) }}" - vids: "{{ item.value.vids | default(omit) }}" - virtual_ip: "{{ item.value.virtual_ip | default(omit) }}" - virtual_mac: "{{ item.value.virtual_mac | default(omit) }}" + name: '{{ item.key }}' + ipv4: '{{ item.value.ipv4 | default(omit) }}' + ipv6: '{{ item.value.ipv6 | default(omit) }}' + alias_name: '{{ item.value.alias_name | default(omit) }}' + addr_method: '{{ item.value.addr_method | default(omit) }}' + speed: '{{ item.value.link_speed | default(omit) }}' + mtu: '{{ item.value.mtu | default(omit) }}' + clagd_enable: '{{ item.value.clagd_enable | default(omit) }}' + clagd_peer_ip: '{{ item.value.clagd_peer_ip | default(omit) }}' + clagd_sys_mac: '{{ item.value.clagd_sys_mac | default(omit) }}' + clagd_priority: '{{ item.value.clagd_priority | default(omit) }}' + vids: '{{ item.value.vids | default(omit) }}' + virtual_ip: '{{ item.value.virtual_ip | default(omit) }}' + virtual_mac: '{{ item.value.virtual_mac | default(omit) }}' 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 }}" + with_dict: '{{ cl_interfaces }}' notify: reload networking - # In vars file # ============ cl_interfaces: - swp1: - alias_name: 'uplink to isp' - ipv4: '10.1.1.1/24' - swp2: - alias_name: 'l2 trunk connection' - vids: [1, 50] - swp3: - speed: 1000 - alias_name: 'connects to 1G link' + swp1: + alias_name: uplink to isp + ipv4: 10.1.1.1/24 + swp2: + alias_name: l2 trunk connection + vids: + - 1 + - 50 + swp3: + speed: 1000 + alias_name: connects to 1G link ########## # br0 interface is configured by cl_bridge ########## - br0.100: - alias_name: 'SVI for vlan 100' - ipv4: '10.2.2.2/24' - ipv6: '10:2:2::2/127' - virtual_ip: '10.2.2.254' - virtual_mac: '00:00:5E:00:10:10' - - + br0.100: + alias_name: SVI for vlan 100 + ipv4: 10.2.2.2/24 + ipv6: '10:2:2::2/127' + virtual_ip: 10.2.2.254 + virtual_mac: 00:00:5E:00:10:10 ''' RETURN = ''' diff --git a/lib/ansible/modules/network/cumulus/cl_ports.py b/lib/ansible/modules/network/cumulus/cl_ports.py index 85b3ed94d02..3bcbcc13e52 100644 --- a/lib/ansible/modules/network/cumulus/cl_ports.py +++ b/lib/ansible/modules/network/cumulus/cl_ports.py @@ -47,24 +47,27 @@ options: - List of 10G ports that will be ganged to form a 40G port. ''' EXAMPLES = ''' -Example playbook entries using the cl_ports module to manage the switch -attributes defined in the ports.conf file on Cumulus Linux +# Use cl_ports module to manage the switch attributes defined in the +# ports.conf file on Cumulus Linux -## Unganged port config using simple args - - name: configure ports.conf setup - cl_ports: - speed_4_by_10g: "swp1, swp32" - speed_40g: "swp2-31" - notify: restart switchd - -## Unganged port configuration on certain ports using complex args - - - name: configure ports.conf setup - cl_ports: - speed_4_by_10g: ['swp1-3', 'swp6'] - speed_40g: ['swp4-5', 'swp7-32'] - notify: restart switchd +## Unganged port configuration on certain ports +- name: configure ports.conf setup + cl_ports: + speed_4_by_10g: + - swp1 + - swp32 + speed_40g: + - swp2-31 +## Unganged port configuration on certain ports +- name: configure ports.conf setup + cl_ports: + speed_4_by_10g: + - swp1-3 + - swp6 + speed_40g: + - swp4-5 + - swp7-32 ''' RETURN = '''