plugins.yml 3.4 KB

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