plugins.yml 3.3 KB

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