plugins.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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:
  48. - "{{ group_names|flatten }}"
  49. notify: restart sensu-client service
  50. - name: Deploy handler plugins
  51. copy:
  52. src: "{{ static_data_store }}/sensu/handlers/"
  53. dest: "{{ sensu_config_path }}/plugins/"
  54. mode: 0755
  55. owner: "{{ sensu_user_name }}"
  56. group: "{{ sensu_group_name }}"
  57. notify: restart sensu-client service
  58. - name: Deploy filter plugins
  59. copy:
  60. src: "{{ static_data_store }}/sensu/filters/"
  61. dest: "{{ sensu_config_path }}/plugins/"
  62. mode: 0755
  63. owner: "{{ sensu_user_name }}"
  64. group: "{{ sensu_group_name }}"
  65. notify: restart sensu-client service
  66. - name: Deploy mutator plugins
  67. copy:
  68. src: "{{ static_data_store }}/sensu/mutators/"
  69. dest: "{{ sensu_config_path }}/plugins/"
  70. mode: 0755
  71. owner: "{{ sensu_user_name }}"
  72. group: "{{ sensu_group_name }}"
  73. notify: restart sensu-client service
  74. - name: Deploy check/handler/filter/mutator definitions to the master
  75. template:
  76. src: "{{ item }}"
  77. dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '') }}"
  78. owner: "{{ sensu_user_name }}"
  79. group: "{{ sensu_group_name }}"
  80. when: sensu_master
  81. with_fileglob:
  82. - "{{ static_data_store }}/sensu/definitions/*"
  83. notify:
  84. - restart sensu-server service
  85. - restart sensu-api service
  86. - restart sensu-enterprise service
  87. - name: Register available client definitions
  88. command: "ls {{ static_data_store }}/sensu/client_definitions"
  89. delegate_to: localhost
  90. register: sensu_available_client_definitions
  91. changed_when: false
  92. become: false
  93. - name: Deploy client definitions
  94. copy:
  95. src: "{{ static_data_store }}/sensu/client_definitions/{{ item }}/"
  96. dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '') }}"
  97. owner: "{{ sensu_user_name }}"
  98. group: "{{ sensu_group_name }}"
  99. when:
  100. - sensu_available_client_definitions is defined
  101. - sensu_available_checks is not skipped
  102. - item in sensu_available_client_definitions.stdout_lines
  103. loop:
  104. - "{{ group_names|flatten }}"
  105. notify: restart sensu-client service