| 1 |
# Test code for the vmware_host_snmp. |
| 2 |
# Copyright: (c) 2018, Christian Kotte <[email protected]> |
| 3 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
|
| 5 |
- import_role: |
| 6 |
name: prepare_vmware_tests |
| 7 |
vars: |
| 8 |
setup_attach_host: true |
| 9 |
|
| 10 |
- name: Enable and configure SNMP community in check mode |
| 11 |
vmware_host_snmp: |
| 12 |
hostname: '{{ esxi1 }}' |
| 13 |
username: '{{ esxi_user }}' |
| 14 |
password: '{{ esxi_password }}' |
| 15 |
community: [ test ] |
| 16 |
state: enabled |
| 17 |
validate_certs: false |
| 18 |
register: snmp_enabled_check_mode |
| 19 |
check_mode: true |
| 20 |
- debug: var=snmp_enabled_check_mode |
| 21 |
- assert: |
| 22 |
that: |
| 23 |
- snmp_enabled_check_mode is defined |
| 24 |
- snmp_enabled_check_mode.changed |
| 25 |
|
| 26 |
- name: Enable and configure SNMP community |
| 27 |
vmware_host_snmp: |
| 28 |
hostname: '{{ esxi1 }}' |
| 29 |
username: '{{ esxi_user }}' |
| 30 |
password: '{{ esxi_password }}' |
| 31 |
community: [ test ] |
| 32 |
state: enabled |
| 33 |
validate_certs: false |
| 34 |
register: snmp_enabled |
| 35 |
- debug: var=snmp_enabled |
| 36 |
- assert: |
| 37 |
that: |
| 38 |
- snmp_enabled is defined |
| 39 |
- snmp_enabled.changed |
| 40 |
|
| 41 |
- name: Enable and configure SNMP system contact and location |
| 42 |
vmware_host_snmp: |
| 43 |
hostname: '{{ esxi1 }}' |
| 44 |
username: '{{ esxi_user }}' |
| 45 |
password: '{{ esxi_password }}' |
| 46 |
sys_contact: "[email protected]" |
| 47 |
sys_location: "Austin, USA" |
| 48 |
state: enabled |
| 49 |
validate_certs: false |
| 50 |
register: snmp_enabled_sys_options |
| 51 |
- debug: var=snmp_enabled_sys_options |
| 52 |
- assert: |
| 53 |
that: |
| 54 |
- snmp_enabled_sys_options is defined |
| 55 |
- snmp_enabled_sys_options.changed |
| 56 |
|
| 57 |
- name: Disable SNMP |
| 58 |
vmware_host_snmp: |
| 59 |
hostname: '{{ esxi1 }}' |
| 60 |
username: '{{ esxi_user }}' |
| 61 |
password: '{{ esxi_password }}' |
| 62 |
state: disabled |
| 63 |
validate_certs: false |
| 64 |
register: snmp_disabled |
| 65 |
- debug: var=snmp_disabled |
| 66 |
- assert: |
| 67 |
that: |
| 68 |
- snmp_disabled is defined |
| 69 |
- snmp_disabled.changed |
| 70 |
|
| 71 |
- name: Enable and configure SNMP community via vCenter in check mode |
| 72 |
vmware_host_snmp: |
| 73 |
hostname: '{{ vcenter_hostname }}' |
| 74 |
username: '{{ vcenter_username }}' |
| 75 |
password: '{{ vcenter_password }}' |
| 76 |
esxi_hostname: '{{ esxi2 }}' |
| 77 |
community: [ test ] |
| 78 |
state: enabled |
| 79 |
validate_certs: false |
| 80 |
register: snmp_enabled_check_mode |
| 81 |
check_mode: true |
| 82 |
- debug: var=snmp_enabled_check_mode |
| 83 |
- assert: |
| 84 |
that: |
| 85 |
- snmp_enabled_check_mode is defined |
| 86 |
- snmp_enabled_check_mode.changed |
| 87 |
|
| 88 |
- name: Enable and configure SNMP community via vCenter |
| 89 |
vmware_host_snmp: |
| 90 |
hostname: '{{ vcenter_hostname }}' |
| 91 |
username: '{{ vcenter_username }}' |
| 92 |
password: '{{ vcenter_password }}' |
| 93 |
esxi_hostname: '{{ esxi2 }}' |
| 94 |
community: [ test ] |
| 95 |
state: enabled |
| 96 |
validate_certs: false |
| 97 |
register: snmp_enabled |
| 98 |
- debug: var=snmp_enabled |
| 99 |
- assert: |
| 100 |
that: |
| 101 |
- snmp_enabled is defined |
| 102 |
- snmp_enabled.changed |
| 103 |
|
| 104 |
- name: Enable and configure SNMP system contact and location via vCenter |
| 105 |
vmware_host_snmp: |
| 106 |
hostname: '{{ vcenter_hostname }}' |
| 107 |
username: '{{ vcenter_username }}' |
| 108 |
password: '{{ vcenter_password }}' |
| 109 |
esxi_hostname: '{{ esxi2 }}' |
| 110 |
sys_contact: "[email protected]" |
| 111 |
sys_location: "Austin, USA" |
| 112 |
state: enabled |
| 113 |
validate_certs: false |
| 114 |
register: snmp_enabled_sys_options |
| 115 |
- debug: var=snmp_enabled_sys_options |
| 116 |
- assert: |
| 117 |
that: |
| 118 |
- snmp_enabled_sys_options is defined |
| 119 |
- snmp_enabled_sys_options.changed |
| 120 |
|
| 121 |
- name: Disable SNMP via vCenter |
| 122 |
vmware_host_snmp: |
| 123 |
hostname: '{{ vcenter_hostname }}' |
| 124 |
username: '{{ vcenter_username }}' |
| 125 |
password: '{{ vcenter_password }}' |
| 126 |
esxi_hostname: '{{ esxi2 }}' |
| 127 |
state: disabled |
| 128 |
validate_certs: false |
| 129 |
register: snmp_disabled |
| 130 |
- debug: var=snmp_disabled |
| 131 |
- assert: |
| 132 |
that: |
| 133 |
- snmp_disabled is defined |
| 134 |
- snmp_disabled.changed |
| 135 |
|
| 136 |
- name: Enable and configure SNMP community in a cluster via vCenter in check mode |
| 137 |
vmware_host_snmp: |
| 138 |
hostname: '{{ vcenter_hostname }}' |
| 139 |
username: '{{ vcenter_username }}' |
| 140 |
password: '{{ vcenter_password }}' |
| 141 |
cluster_name: "{{ ccr1 }}" |
| 142 |
community: [ test2 ] |
| 143 |
state: enabled |
| 144 |
validate_certs: false |
| 145 |
register: snmp_enabled_check_mode |
| 146 |
check_mode: true |
| 147 |
- debug: var=snmp_enabled_check_mode |
| 148 |
- assert: |
| 149 |
that: |
| 150 |
- snmp_enabled_check_mode is defined |
| 151 |
- snmp_enabled_check_mode.changed |
| 152 |
|
| 153 |
- name: Enable and configure SNMP community in a cluster via vCenter |
| 154 |
vmware_host_snmp: |
| 155 |
hostname: '{{ vcenter_hostname }}' |
| 156 |
username: '{{ vcenter_username }}' |
| 157 |
password: '{{ vcenter_password }}' |
| 158 |
cluster_name: "{{ ccr1 }}" |
| 159 |
community: [ test2 ] |
| 160 |
state: enabled |
| 161 |
validate_certs: false |
| 162 |
register: snmp_enabled |
| 163 |
- debug: var=snmp_enabled |
| 164 |
- assert: |
| 165 |
that: |
| 166 |
- snmp_enabled is defined |
| 167 |
- snmp_enabled.changed |
| 168 |
|
| 169 |
- name: Enable and configure SNMP system contact and location in a cluster via vCenter |
| 170 |
vmware_host_snmp: |
| 171 |
hostname: '{{ vcenter_hostname }}' |
| 172 |
username: '{{ vcenter_username }}' |
| 173 |
password: '{{ vcenter_password }}' |
| 174 |
cluster_name: "{{ ccr1 }}" |
| 175 |
sys_contact: "[email protected]" |
| 176 |
sys_location: "Austin, USA" |
| 177 |
state: enabled |
| 178 |
validate_certs: false |
| 179 |
register: snmp_enabled_sys_options |
| 180 |
- debug: var=snmp_enabled_sys_options |
| 181 |
- assert: |
| 182 |
that: |
| 183 |
- snmp_enabled_sys_options is defined |
| 184 |
- snmp_enabled_sys_options.changed |
| 185 |
|
| 186 |
- name: Disable SNMP in a cluster via vCenter |
| 187 |
vmware_host_snmp: |
| 188 |
hostname: '{{ vcenter_hostname }}' |
| 189 |
username: '{{ vcenter_username }}' |
| 190 |
password: '{{ vcenter_password }}' |
| 191 |
cluster_name: "{{ ccr1 }}" |
| 192 |
state: disabled |
| 193 |
validate_certs: false |
| 194 |
register: snmp_disabled |
| 195 |
- debug: var=snmp_disabled |
| 196 |
- assert: |
| 197 |
that: |
| 198 |
- snmp_disabled is defined |
| 199 |
- snmp_disabled.changed |