plugins.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. file:
  14. state: directory
  15. dest: "{{ static_data_store }}/sensu/{{ item }}"
  16. delegate_to: localhost
  17. become: no
  18. loop:
  19. - checks
  20. - filters
  21. - handlers
  22. - mutators
  23. - definitions
  24. - client_definitions
  25. - name: Ensure any remote plugins defined are present
  26. shell: umask 0022; sensu-install -p {{ item }}
  27. loop: "{{ sensu_remote_plugins }}"
  28. changed_when: false
  29. when: sensu_remote_plugins | length > 0
  30. - name: Register available checks
  31. command: "ls {{ static_data_store }}/sensu/checks"
  32. delegate_to: localhost
  33. register: sensu_available_checks
  34. changed_when: false
  35. become: false
  36. - name: Deploy check plugins
  37. copy:
  38. src: "{{ static_data_store }}/sensu/checks/{{ item }}/"
  39. dest: "{{ sensu_config_path }}/plugins/"
  40. mode: 0755
  41. owner: "{{ sensu_user_name }}"
  42. group: "{{ sensu_group_name }}"
  43. when:
  44. - sensu_available_checks is defined
  45. - sensu_available_checks is not skipped
  46. - item in sensu_available_checks.stdout_lines
  47. loop: "{{ group_names|flatten }}"
  48. notify: restart sensu-client service
  49. - name: Deploy handler plugins
  50. copy:
  51. src: "{{ static_data_store }}/sensu/handlers/"
  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 filter plugins
  58. copy:
  59. src: "{{ static_data_store }}/sensu/filters/"
  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 mutator plugins
  66. copy:
  67. src: "{{ static_data_store }}/sensu/mutators/"
  68. dest: "{{ sensu_config_path }}/plugins/"
  69. mode: 0755
  70. owner: "{{ sensu_user_name }}"
  71. group: "{{ sensu_group_name }}"
  72. notify: restart sensu-client service
  73. - name: Deploy check/handler/filter/mutator definitions to the master
  74. template:
  75. src: "{{ item }}"
  76. dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '') }}"
  77. owner: "{{ sensu_user_name }}"
  78. group: "{{ sensu_group_name }}"
  79. when: sensu_master
  80. with_fileglob:
  81. - "{{ static_data_store }}/sensu/definitions/*"
  82. notify:
  83. - restart sensu-server service
  84. - restart sensu-api service
  85. - restart sensu-enterprise service
  86. - name: Register available client definitions
  87. command: "ls {{ static_data_store }}/sensu/client_definitions"
  88. delegate_to: localhost
  89. register: sensu_available_client_definitions
  90. changed_when: false
  91. become: false
  92. - name: Deploy client definitions
  93. copy:
  94. src: "{{ static_data_store }}/sensu/client_definitions/{{ item }}/"
  95. dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '') }}"
  96. owner: "{{ sensu_user_name }}"
  97. group: "{{ sensu_group_name }}"
  98. when:
  99. - sensu_available_client_definitions is defined
  100. - sensu_available_checks is not skipped
  101. - item in sensu_available_client_definitions.stdout_lines
  102. loop: "{{ group_names|flatten }}"
  103. notify: restart sensu-client service