diff --git a/defaults/main.yml b/defaults/main.yml index 2f1d4e0f2bcd93c7cd7623c62b1c73a7e96636ab..4938622f3c37c35dc7cc799f5e5499a9cd73e7d8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,9 +14,7 @@ sd_groups: mysql: 'none' proxy: 'none' - sd_repo_public_key_uri: 'https://www.serverdensity.com/downloads/boxedice-public.key' sd_agent_plugins_dir: '/usr/bin/sd-agent/plugins' -sd_plugins_files_dir: "{{inventory_dir}}/files/sd-plugins" +sd_plugins_files_dir: "{{ inventory_dir }}/files/sd-plugins" sd_template_config: 'config.cfg' -... diff --git a/handlers/main.yml b/handlers/main.yml index 33555a256e78ad6adeb368454b574fbc65a67f70..a69488ad058b1c70ceb7112f87218319cbe5fe19 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,12 @@ --- # file: roles/serverdensity/handlers/main.yml -- name: 'ServerDensity | Restart Agent' - service: name=sd-agent state=restarted +- name: "ServerDensity | Restart Agent" + service: + name=sd-agent + state=restarted + +- name: "ServerDensity | Restart Apache" + service: + name=apache2 + state=restarted diff --git a/tasks/apache.yml b/tasks/apache.yml new file mode 100644 index 0000000000000000000000000000000000000000..b9760826eef63b68a1eb2ac13892e776e62a656f --- /dev/null +++ b/tasks/apache.yml @@ -0,0 +1,23 @@ +--- +# file: roles/serverdensity/tasks/apache.yml + +- name: "ServerDensity | Apache | Enable some required modules" + apache_module: + name={{ item }} + state=present + with_items: + - status + notify: "ServerDensity | Restart Apache" + +- name: "ServerDensity | Apache | Configuration file for ServerDensity" + template: + src=etc-apache2-sites-available-sd-agent + dest=/etc/apache2/sites-available/sd-agent{{ apache_conf_ext }} + owner=root + group=root + mode=0644 + notify: "ServerDensity | Restart Apache" + +- name: "ServerDensity | Apache | Enable the sd-agent site" + command: a2ensite sd-agent creates=/etc/apache2/sites-enabled/sd-agent{{ apache_conf_ext }} + notify: "ServerDensity | Restart Apache" diff --git a/tasks/main.yml b/tasks/main.yml index 2faf99ac6d341dc9187cf8360053fb51e8a6192e..54ef924abe6f6761246c951b584667030991e6e2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -49,3 +49,6 @@ mode=0644 when: sd_agent_key != '' notify: 'ServerDensity | Restart Agent' + +- include: apache.yml + when: sd_groups.apache != 'none' and inventory_hostname in groups[sd_groups.apache] diff --git a/templates/config.cfg b/templates/config.cfg index e697d88242387b970e6694ccc4534a6390650b45..354675cf08e9495b4c7dafaa812e8350a99fa060 100644 --- a/templates/config.cfg +++ b/templates/config.cfg @@ -3,17 +3,17 @@ # Plugins: http://plugins.serverdensity.com/ [Main] -sd_url: {{sd_url}} -agent_key: {{sd_agent_key}} +sd_url: {{ sd_url }} +agent_key: {{ sd_agent_key }} -plugin_directory: {{ sd_agent_plugins_dir }} -logging_level: {{sd_logging_level}} +plugin_directory: {{ sd_agent_plugins_dir }} +logging_level: {{ sd_logging_level }} {% if sd_groups.apache != 'none' and inventory_hostname in groups[sd_groups.apache] %} # Apache # See https://support.serverdensity.com/hc/en-us/articles/201253343-Apache-monitoring-Linux-Mac-and-FreeBSD -apache_status_url: http://{{inventory_hostname}}/server-status/?auto +apache_status_url: http://{{ inventory_hostname }}/server-status/?auto apache_status_user: apache_status_pass: {% endif %} @@ -28,6 +28,6 @@ mysql_pass: root {% endif %} {% if sd_groups.proxy != 'none' and inventory_hostname in groups[sd_groups.proxy] %} -haproxy_svname: {{inventory_hostname}} +haproxy_svname: {{ inventory_hostname }} haproxy_url: http://127.0.0.1:7000/haproxy_stats {% endif %} diff --git a/templates/etc-apache2-sites-available-sd-agent b/templates/etc-apache2-sites-available-sd-agent new file mode 100644 index 0000000000000000000000000000000000000000..95ad829e77b51b1a783d4e537c0c431b82991d4e --- /dev/null +++ b/templates/etc-apache2-sites-available-sd-agent @@ -0,0 +1,9 @@ +<VirtualHost *:80> + <Location /server-status> + SetHandler server-status + Order Deny,Allow + Deny from all + Allow from 127.0.0.1{% for address in ansible_all_ipv4_addresses %} {{ address }}{% endfor %} + </Location> + ServerName {{ inventory_hostname }} +</VirtualHost>