summaryrefslogtreecommitdiff
path: root/test/integration/targets/prepare_ios_tests/tasks/main.yml
blob: d0970a9b0c614719a01b88b8f0b9c8398a021b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---

- name: Ensure we have loopback 888 for testing
  ios_config:
    src: config.j2
  connection: network_cli
  become: yes

# Some AWS hostnames can be longer than those allowed by the system we are testing
# Truncate the hostname
# http://jinja.pocoo.org/docs/2.9/templates/#truncate
- set_fact:
    shorter_hostname: '{{ inventory_hostname_short| truncate(10, True, "") }}'

- name: "Discover IOS L2/L3 switch type"
  ios_command:
    commands: ['show version']
  connection: network_cli
  become: yes
  register: result

- set_fact: switch_type=""

- set_fact: switch_type="L2"
  when: '"l2" in result.stdout[0]'

- block:
    - name: Set test interface to GigabitEthernet0/1 as we are on Cisco IOS
      set_fact: test_interface=GigabitEthernet0/1
    - name: Set test interface 2 to GigabitEthernet0/2 as we are on Cisco IOS
      set_fact: test_interface2=GigabitEthernet0/2
  when: "'Cisco IOS' in result.stdout[0]"

- block:
    - name: Set test interface to GigabitEthernet2 as we are on Cisco IOS-XE
      set_fact: test_interface=GigabitEthernet2
    - name: Disable autonegotiation on GigabitEthernet2
      ios_config:
        lines:
          - no negotiation auto
        parents: int GigabitEthernet2
        authorize: yes

    - name: Set test interface 2 to GigabitEthernet3 as we are on Cisco IOS-XE
      set_fact: test_interface2=GigabitEthernet3
    - name: Disable autonegotiation on GigabitEthernet3
      ios_config:
        lines:
          - no negotiation auto
        parents: int GigabitEthernet3
        authorize: yes
  when: "'Cisco IOS-XE' in result.stdout[0]"