Browse Source

Merge branch 'master' into feature/debian-ubuntu-switch-rabbit-to-bintray

Jared 8 years ago
parent
commit
892c6b2c79
2 changed files with 47 additions and 0 deletions
  1. 28 0
      docs/dynamic_checks.md
  2. 19 0
      tasks/plugins.yml

+ 28 - 0
docs/dynamic_checks.md

@@ -40,6 +40,11 @@ data/static
     |   |-- smartos_check_cpu.json.j2
     |   |-- smartos_check_cpu.json.j2
     |   |-- smartos_check_disk.json.j2
     |   |-- smartos_check_disk.json.j2
     |   `-- smartos_check_mem.json.j2
     |   `-- smartos_check_mem.json.j2
+    |-- client-definitions
+    |   |-- rabbitmq_servers
+    |   |   `-- check_users.json.j2
+    |   `-- webservers
+    |       `-- check_uptime.json.j2
     |-- handlers
     |-- handlers
     |   `-- pushover.rb
     |   `-- pushover.rb
     `-- mutators
     `-- mutators
@@ -106,6 +111,29 @@ This will [register](http://docs.ansible.com/playbooks_conditionals.html#registe
 
 
 And, because nodes can of course be members of more than just one group, checks will be deployed in full to nodes that belong to several groups!
 And, because nodes can of course be members of more than just one group, checks will be deployed in full to nodes that belong to several groups!
 
 
+Additionally, standalone checks can be distributed to hosts based on group membership. These definitions are located in the client-definitions folder. These will be deployed to the configuration directory of the clients.
+
+These are deployed with the following pair of plays, also in the `tasks/plugins.yml` playbook:
+``` yaml
+- name: Register available client definitions
+  local_action: command ls {{ static_data_store }}/sensu/client_definitions
+  register: sensu_available_client_definitions
+  changed_when: false
+  become: false
+
+- name: Deploy client definitions
+  copy:
+    src: "{{ static_data_store }}/sensu/client_definitions/{{ item }}/"
+    dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '')}}"
+    mode: 0755
+    owner: "{{ sensu_user_name }}"
+    group: "{{ sensu_group_name }}"
+  when: "sensu_available_client_definitions is defined and item in sensu_available_client_definitions.stdout_lines"
+  with_flattened:
+    - "{{ group_names }}"
+  notify: restart sensu-client service
+```
+
 ## Picking up changes on the fly
 ## Picking up changes on the fly
 Let's say, for some reason, one of your nodes decides to switch roles, or take on the responsibility of another role.
 Let's say, for some reason, one of your nodes decides to switch roles, or take on the responsibility of another role.
 You've got a webserver, who all of a sudden you decide "this guy should be running redis too". No problem!
 You've got a webserver, who all of a sudden you decide "this guy should be running redis too". No problem!

+ 19 - 0
tasks/plugins.yml

@@ -18,6 +18,8 @@
       - filters
       - filters
       - handlers
       - handlers
       - mutators
       - mutators
+      - definitions
+      - client_definitions
 
 
   - name: Ensure any remote plugins defined are present
   - name: Ensure any remote plugins defined are present
     shell: sensu-install -p {{ item }}
     shell: sensu-install -p {{ item }}
@@ -83,3 +85,20 @@
       - restart sensu-server service
       - restart sensu-server service
       - restart sensu-api service
       - restart sensu-api service
       - restart sensu-enterprise service
       - restart sensu-enterprise service
+
+  - name: Register available client definitions
+    local_action: command ls {{ static_data_store }}/sensu/client_definitions
+    register: sensu_available_client_definitions
+    changed_when: false
+    become: false
+
+  - name: Deploy client definitions
+    copy:
+      src: "{{ static_data_store }}/sensu/client_definitions/{{ item }}/"
+      dest: "{{ sensu_config_path }}/conf.d/{{ item | basename | regex_replace('.j2', '')}}"
+      owner: "{{ sensu_user_name }}"
+      group: "{{ sensu_group_name }}"
+    when: "sensu_available_client_definitions is defined and item in sensu_available_client_definitions.stdout_lines"
+    with_flattened:
+      - "{{ group_names }}"
+    notify: restart sensu-client service