|
| 1 | +--- |
| 2 | +## |
| 3 | +## |
| 4 | +### NETBOX_CONTACT_GROUP |
| 5 | +## |
| 6 | +## |
| 7 | +- name: 1 - Test contact group creation |
| 8 | + netbox.netbox.netbox_contact_group: |
| 9 | + netbox_url: http://localhost:32768 |
| 10 | + netbox_token: "0123456789abcdef0123456789abcdef01234567" |
| 11 | + data: |
| 12 | + name: Contact Group 1 |
| 13 | + register: test_one |
| 14 | + |
| 15 | +- name: 1 - ASSERT |
| 16 | + ansible.builtin.assert: |
| 17 | + that: |
| 18 | + - test_one is changed |
| 19 | + - test_one['diff']['before']['state'] == "absent" |
| 20 | + - test_one['diff']['after']['state'] == "present" |
| 21 | + - test_one['contact_group']['name'] == "Contact Group 1" |
| 22 | + - test_one['msg'] == "contact_group Contact Group 1 created" |
| 23 | + |
| 24 | +- name: Test duplicate contact group |
| 25 | + netbox.netbox.netbox_contact_group: |
| 26 | + netbox_url: http://localhost:32768 |
| 27 | + netbox_token: "0123456789abcdef0123456789abcdef01234567" |
| 28 | + data: |
| 29 | + name: Contact Group 1 |
| 30 | + register: test_two |
| 31 | + |
| 32 | +- name: 2 - ASSERT |
| 33 | + ansible.builtin.assert: |
| 34 | + that: |
| 35 | + - not test_two['changed'] |
| 36 | + - test_two['contact_group']['name'] == "Contact Group 1" |
| 37 | + - test_two['msg'] == "contact_group Contact Group 1 already exists" |
| 38 | + |
| 39 | +- name: 3 - Test update |
| 40 | + netbox.netbox.netbox_contact_group: |
| 41 | + netbox_url: http://localhost:32768 |
| 42 | + netbox_token: "0123456789abcdef0123456789abcdef01234567" |
| 43 | + data: |
| 44 | + name: Contact Group 1 |
| 45 | + description: The first contact group |
| 46 | + register: test_three |
| 47 | + |
| 48 | +- name: 3 - ASSERT |
| 49 | + ansible.builtin.assert: |
| 50 | + that: |
| 51 | + - test_three is changed |
| 52 | + - test_three['diff']['after']['description'] == "The first contact group" |
| 53 | + - test_three['contact_group']['name'] == "Contact Group 1" |
| 54 | + - test_three['contact_group']['description'] == "The first contact group" |
| 55 | + - test_three['msg'] == "contact_group Contact Group 1 updated" |
| 56 | + |
| 57 | +- name: 4 - Test delete |
| 58 | + netbox.netbox.netbox_contact_group: |
| 59 | + netbox_url: http://localhost:32768 |
| 60 | + netbox_token: "0123456789abcdef0123456789abcdef01234567" |
| 61 | + data: |
| 62 | + name: Contact Group 1 |
| 63 | + state: absent |
| 64 | + register: test_four |
| 65 | + |
| 66 | +- name: 4 - ASSERT |
| 67 | + ansible.builtin.assert: |
| 68 | + that: |
| 69 | + - test_four is changed |
| 70 | + - test_four['diff']['before']['state'] == "present" |
| 71 | + - test_four['diff']['after']['state'] == "absent" |
| 72 | + - test_four['msg'] == "contact_group Contact Group 1 deleted" |
| 73 | + |
| 74 | +- name: 5 - Create contact group with all parameters |
| 75 | + netbox.netbox.netbox_contact_group: |
| 76 | + netbox_url: http://localhost:32768 |
| 77 | + netbox_token: "0123456789abcdef0123456789abcdef01234567" |
| 78 | + data: |
| 79 | + name: Contact Group Parent |
| 80 | + slug: the-parent-contact-group |
| 81 | + description: The parent contact group |
| 82 | + tags: |
| 83 | + - tagA |
| 84 | + - tagB |
| 85 | + - tagC |
| 86 | + state: present |
| 87 | + register: test_five |
| 88 | + |
| 89 | +- name: 5 - ASSERT |
| 90 | + ansible.builtin.assert: |
| 91 | + that: |
| 92 | + - test_five is changed |
| 93 | + - test_five['diff']['before']['state'] == "absent" |
| 94 | + - test_five['diff']['after']['state'] == "present" |
| 95 | + - test_five['contact_group']['name'] == "Contact Group Parent" |
| 96 | + - test_five['contact_group']['slug'] == "the-parent-contact-group" |
| 97 | + - test_five['contact_group']['description'] == "The parent contact group" |
| 98 | + - test_five['contact_group']['tags'] | length == 3 |
| 99 | + - test_five['msg'] == "contact_group Contact Group Parent created" |
| 100 | + |
| 101 | +- name: 6 - Create contact group with parent contact group |
| 102 | + netbox.netbox.netbox_contact_group: |
| 103 | + netbox_url: http://localhost:32768 |
| 104 | + netbox_token: "0123456789abcdef0123456789abcdef01234567" |
| 105 | + data: |
| 106 | + name: Contact Group Child |
| 107 | + parent_contact_group: Contact Group Parent |
| 108 | + state: present |
| 109 | + register: test_six |
| 110 | + |
| 111 | +- name: 6 - ASSERT |
| 112 | + ansible.builtin.assert: |
| 113 | + that: |
| 114 | + - test_six is changed |
| 115 | + - test_six['diff']['before']['state'] == "absent" |
| 116 | + - test_six['diff']['after']['state'] == "present" |
| 117 | + - test_six['contact_group']['name'] == "Contact Group Child" |
| 118 | + - test_six['contact_group']['parent'] == test_five['contact_group']['id'] |
| 119 | + - test_six['msg'] == "contact_group Contact Group Child created" |
0 commit comments