|  | 
|  | 1 | +--- | 
|  | 2 | +- name: Test juniper_junos_config module | 
|  | 3 | +  hosts: all | 
|  | 4 | +  connection: local | 
|  | 5 | +  gather_facts: no | 
|  | 6 | +  roles: | 
|  | 7 | +    - Juniper.junos | 
|  | 8 | +  tasks: | 
|  | 9 | +################# | 
|  | 10 | +    - name: Retrieve the committed configuration | 
|  | 11 | +      juniper_junos_config: | 
|  | 12 | +        retrieve: 'committed' | 
|  | 13 | +        diff: false | 
|  | 14 | +        check: false | 
|  | 15 | +        commit: false | 
|  | 16 | +      register: test1 | 
|  | 17 | +      ignore_errors: True | 
|  | 18 | +      tags: [ test1 ] | 
|  | 19 | + | 
|  | 20 | +    - name: Check TEST 1 | 
|  | 21 | +      assert: | 
|  | 22 | +        that: | 
|  | 23 | +          - test1.config | 
|  | 24 | +          - "'host-name choc-qfx-a;' in test1.config" | 
|  | 25 | +################# | 
|  | 26 | +    - name: Append .foo to the hostname using private config mode. | 
|  | 27 | +      juniper_junos_config: | 
|  | 28 | +        config_mode: 'private' | 
|  | 29 | +        load: 'merge' | 
|  | 30 | +        lines: | 
|  | 31 | +          - "set system host-name {{ inventory_hostname }}.foo" | 
|  | 32 | +      register: test2 | 
|  | 33 | +      ignore_errors: True | 
|  | 34 | +      tags: [ test2 ] | 
|  | 35 | + | 
|  | 36 | +    - name: Check TEST 2 | 
|  | 37 | +      assert: | 
|  | 38 | +        that: | 
|  | 39 | +          - test2.diff_lines | 
|  | 40 | +          - "'+  host-name choc-qfx-a.foo;' in test2.diff_lines" | 
|  | 41 | +################# | 
|  | 42 | +    - name: Rollback to the previous config. | 
|  | 43 | +      juniper_junos_config: | 
|  | 44 | +        config_mode: 'private' | 
|  | 45 | +        rollback: "1" | 
|  | 46 | +      register: test3 | 
|  | 47 | +      ignore_errors: True | 
|  | 48 | +      tags: [ test3 ] | 
|  | 49 | + | 
|  | 50 | +    - name: Check TEST 3 | 
|  | 51 | +      assert: | 
|  | 52 | +        that: | 
|  | 53 | +          - test3.diff_lines | 
|  | 54 | +          - "'-  host-name choc-qfx-a.foo;' in test3.diff_lines" | 
|  | 55 | +################# | 
|  | 56 | +    - name: Creates directory | 
|  | 57 | +      file: | 
|  | 58 | +        path: out | 
|  | 59 | +        state: directory | 
|  | 60 | + | 
|  | 61 | +    - name: Configure LLDP | 
|  | 62 | +      juniper_junos_config: | 
|  | 63 | +        load: 'merge' | 
|  | 64 | +        lines: | 
|  | 65 | +          - "set protocols lldp advertisement-interval 30" | 
|  | 66 | +          - "set protocols lldp transmit-delay 2" | 
|  | 67 | +          - "set protocols lldp hold-multiplier 4" | 
|  | 68 | +          - "set protocols lldp ptopo-configuration-trap-interval 30" | 
|  | 69 | +          - "set protocols lldp ptopo-configuration-maximum-hold-time 300" | 
|  | 70 | +          - "set protocols lldp lldp-configuration-notification-interval 30" | 
|  | 71 | +          - "set protocols lldp interface all disable" | 
|  | 72 | +          - "set protocols lldp interface ge-1/1/1" | 
|  | 73 | +        format: 'set' | 
|  | 74 | +        comment: 'Start LLDP with given options' | 
|  | 75 | +        dest_dir: './out' | 
|  | 76 | +      register: test4 | 
|  | 77 | +      ignore_errors: True | 
|  | 78 | +      tags: [ test4 ] | 
|  | 79 | + | 
|  | 80 | +    - name: Rollback to the rescue config. | 
|  | 81 | +      juniper_junos_config: | 
|  | 82 | +        rollback: 'rescue' | 
|  | 83 | + | 
|  | 84 | +    - name: Check out/choc-qfx-a.diff exists | 
|  | 85 | +      stat: | 
|  | 86 | +        path: out/choc-qfx-a.diff | 
|  | 87 | +      register: stat_result_1 | 
|  | 88 | + | 
|  | 89 | +    - name: Check TEST 4 | 
|  | 90 | +      assert: | 
|  | 91 | +        that: | 
|  | 92 | +          - stat_result_1.stat.exists == True | 
|  | 93 | +          - test4.diff_lines | 
|  | 94 | +          - "'+          interface ge-1/1/1;' in test4.diff_lines" | 
|  | 95 | + | 
|  | 96 | +    - name: Clean up TEST 4 | 
|  | 97 | +      file: | 
|  | 98 | +        path: out | 
|  | 99 | +        state: absent | 
|  | 100 | +################# | 
|  | 101 | +    - name: Retrieve [edit system services] of current committed config. | 
|  | 102 | +      juniper_junos_config: | 
|  | 103 | +        retrieve: 'committed' | 
|  | 104 | +        filter: 'system/services' | 
|  | 105 | +        diff: true | 
|  | 106 | +        check: false | 
|  | 107 | +        commit: false | 
|  | 108 | +      register: test5 | 
|  | 109 | +      ignore_errors: True | 
|  | 110 | +      tags: [ test5 ] | 
|  | 111 | + | 
|  | 112 | +    - name: Check TEST 5 | 
|  | 113 | +      assert: | 
|  | 114 | +        that: | 
|  | 115 | +          - test5.failed == False | 
|  | 116 | +          - "'system {' in test5.config_lines" | 
|  | 117 | +################# | 
|  | 118 | +#TODO: Add tests for commit check and commit confirmed workflows | 
0 commit comments