Skip to content

Commit

Permalink
Update Galaxy info
Browse files Browse the repository at this point in the history
Add no_log for running-config output
Check for _eos_config before running show run all again
  • Loading branch information
phil-dileo committed Feb 11, 2016
1 parent 2b6f5f2 commit 88c4727
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2
4 changes: 4 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ galaxy_info:
description: Role for managing layer 2 bridging configuration
company: Arista
license: BSD-3
platforms:
- name: eos
versions:
- all
min_ansible_version: 2.1.0
categories:
- networking
Expand Down
16 changes: 10 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Force CLI for eos_command to ensure running config is returned properly
- name: Gather EOS configuration
eos_command:
commands='show running-config all'
commands='show running-config all | exclude \.\*'
provider={{ provider|default(omit) }}
auth_pass={{ auth_pass|default(omit) }}
authorize={{ authorize|default(omit) }}
Expand All @@ -13,15 +13,19 @@
use_ssl={{ use_ssl|default(omit) }}
username={{ username|default(omit) }}
register: output
no_log: '{{ no_log|default(true) }}'
when: _eos_config is not defined

- set_fact:
base_config='{{ output.result[0] }}'
_eos_config='{{ output.result[0] }}'
no_log: "{{ no_log|default(true) }}"
when: _eos_config is not defined

- name: Arista EOS VLAN resources
eos_template:
src=vlan.j2
include_defaults=True
config={{ base_config|default(omit) }}
config={{ _eos_config|default(omit) }}
provider={{ provider|default(omit) }}
auth_pass={{ auth_pass|default(omit) }}
authorize={{ authorize|default(omit) }}
Expand All @@ -32,13 +36,13 @@
use_ssl={{ use_ssl|default(omit) }}
username={{ username|default(omit) }}
when: vlans is defined
with_items: '{{ vlans }}'
with_items: '{{ vlans|default([]) }}'

- name: Arista EOS switchport resources
eos_template:
src=switchport.j2
include_defaults=True
config={{ base_config|default(omit) }}
config={{ _eos_config|default(omit) }}
provider={{ provider|default(omit) }}
auth_pass={{ auth_pass|default(omit) }}
authorize={{ authorize|default(omit) }}
Expand All @@ -49,4 +53,4 @@
use_ssl={{ use_ssl|default(omit) }}
username={{ username|default(omit) }}
when: switchports is defined
with_items: '{{ switchports }}'
with_items: '{{ switchports|default([]) }}'
4 changes: 2 additions & 2 deletions templates/switchport.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface {{ item.name }}
no switchport
{# If we find existing switchport config, then default settings #}
{# These default commands only run the first time absent is called #}
{% set switchport_block = base_config | config_block('interface ' ~ item.name, indent=3) %}
{% set switchport_block = _eos_config | config_block('interface ' ~ item.name, indent=3) %}
{% if switchport_block %}
{% if switchport_block | join('\n') | re_search('^switchport$') %}
default switchport mode
Expand Down Expand Up @@ -36,7 +36,7 @@ interface {{ item.name }}

{# Determine which trunk groups need to be removed #}
{% if eos_purge_switchport_trunk_groups %}
{% set switchport_block = base_config | config_block('interface ' ~ item.name, indent=3) %}
{% set switchport_block = _eos_config | config_block('interface ' ~ item.name, indent=3) %}
{% if switchport_block %}
{% set current = switchport_block | join('\n') | re_findall('^switchport trunk group (\S+)') %}
{% set to_remove = current | symmetric_difference(item.trunk_groups) %}
Expand Down
4 changes: 2 additions & 2 deletions templates/vlan.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% set state = item.state|default(default_vlan_state) %}

{% if state == 'absent' %}
{% set vlan_block = base_config | config_block('vlan ' ~ item.vlanid, indent=3) %}
{% set vlan_block = _eos_config | config_block('vlan ' ~ item.vlanid, indent=3) %}
{% if vlan_block %}
no vlan {{ item.vlanid }}
{% endif %}
Expand All @@ -24,7 +24,7 @@ vlan {{ item.vlanid }}

{# Determine which trunk groups need to be removed #}
{% if eos_purge_vlan_trunk_groups %}
{% set vlan_block = base_config | config_block('vlan ' ~ item.vlanid, indent=3) %}
{% set vlan_block = _eos_config | config_block('vlan ' ~ item.vlanid, indent=3) %}
{% if vlan_block %}
{% set current = vlan_block | join('\n') | re_findall('^trunk group (\S+)') %}
{% set to_remove = current | symmetric_difference(item.trunk_groups) %}
Expand Down

0 comments on commit 88c4727

Please sign in to comment.