set_snmp.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Get auth string
  16. shell: echo -n {{ powervault_me4_username }}_{{ powervault_me4_password }} | sha256sum
  17. register: snmp_auth_string
  18. changed_when: false
  19. ignore_errors: yes
  20. tags: install
  21. - name: Get session key
  22. uri:
  23. url: https://{{ inventory_hostname }}/api/login/{{ snmp_auth_string.stdout | replace(" -", "") }}
  24. method: GET
  25. headers:
  26. {'datatype': 'json'}
  27. validate_certs: no
  28. register: snmp_session_key
  29. tags: install
  30. - name: Set snmp parameters
  31. uri:
  32. url: https://{{ inventory_hostname }}/api/set/snmp-parameters/enable/{{ powervault_me4_snmp_notify_level }}/add-trap-host/{{ snmp_trap_destination }}/read-community/{{ snmp_community_name }}
  33. method: GET
  34. body_format: json
  35. validate_certs: no
  36. use_proxy: no
  37. headers:
  38. {'sessionKey': "{{ snmp_session_key.json.status[0].response }}", 'datatype':'json'}
  39. register: snmp
  40. tags: install