plugins.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ---
  2. # tasks/plugins.yml: Deploy available checks/plugins/handlers/filters/mutators
  3. - include_vars: "{{ ansible_distribution }}.yml"
  4. - name: Ensure Sensu plugin directory exists
  5. file:
  6. dest: "{{ sensu_config_path }}/plugins"
  7. state: directory
  8. owner: "{{ sensu_user_name }}"
  9. group: "{{ sensu_group_name }}"
  10. - name: Ensure local directories exist
  11. local_action: file state=directory dest="{{ static_data_store }}/sensu/{{ item }}"
  12. become: no
  13. with_items:
  14. - checks
  15. - filters
  16. - handlers
  17. - mutators
  18. - definitions
  19. - client_definitions
  20. - name: Ensure any remote plugins defined are present
  21. shell: umask 0022; sensu-install -p {{ item }}
  22. with_items: "{{ sensu_remote_plugins }}"
  23. changed_when: false
  24. when: sensu_remote_plugins | length > 0
  25. - name: Register available checks
  26. local_action: command ls {{ static_data_store }}/sensu/checks
  27. register: sensu_available_checks
  28. changed_when: false
  29. become: false
  30. - name: Deploy check plugins
  31. copy:
  32. src: "{{ static_data_store }}/sensu/checks/{{ item }}/"
  33. dest: "{{ sensu_config_path }}/plugins/"
  34. mode: 0755
  35. owner: "{{ sensu_user_name }}"
  36. group: "{{ sensu_group_name }}"
  37. when: "sensu_available_checks is defined and item in sensu_available_checks.stdout_lines"
  38. with_flattened:
  39. - "{{ group_names }}"
  40. notify: restart sensu-client service
  41. - name: Deploy handler plugins
  42. copy:
  43. src: "{{ static_data_store }}/sensu/handlers/"
  44. dest: "{{ sensu_config_path }}/plugins/"
  45. mode: 0755
  46. owner: "{{ sensu_user_name }}"
  47. group: "{{ sensu_group_name }}"
  48. notify: restart sensu-client service
  49. - name: Deploy filter plugins
  50. copy:
  51. src: "{{ static_data_store }}/sensu/filters/"
  52. dest: "{{ sensu_config_path }}/plugins/"
  53. mode: 0755
  54. owner: "{{ sensu_user_name }}"
  55. group: "{{ sensu_group_name }}"
  56. notify: restart sensu-client service
  57. - name: Deploy mutator plugins
  58. copy:
  59. src: "{{ static_data_store }}/sensu/mutators/"
  60. dest: "{{ sensu_config_path }}/plugins/"
  61. mode: 0755
  62. owner: "{{ sensu_user_name }}"
  63. group: "{{ sensu_group_name }}"
  64. notify: restart sensu-client service
  65. - name: Deploy check/handler/filter/mutator definitions to the master
  66. template:
  67. src: "{{ item }}"
  68. dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '')}}"
  69. owner: "{{ sensu_user_name }}"
  70. group: "{{ sensu_group_name }}"
  71. when: sensu_master
  72. with_fileglob:
  73. - "{{ static_data_store }}/sensu/definitions/*"
  74. notify:
  75. - restart sensu-server service
  76. - restart sensu-api service
  77. - restart sensu-enterprise service
  78. - name: Register available client definitions
  79. local_action: command ls {{ static_data_store }}/sensu/client_definitions
  80. register: sensu_available_client_definitions
  81. changed_when: false
  82. become: false
  83. - name: Deploy client definitions
  84. copy:
  85. src: "{{ static_data_store }}/sensu/client_definitions/{{ item }}/"
  86. dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '')}}"
  87. owner: "{{ sensu_user_name }}"
  88. group: "{{ sensu_group_name }}"
  89. when: "sensu_available_client_definitions is defined and item in sensu_available_client_definitions.stdout_lines"
  90. with_flattened:
  91. - "{{ group_names }}"
  92. notify: restart sensu-client service