diff --git a/doc/README.md b/doc/README.md index 0fa64771ffc786ee6748304a48886013cef72d3d..88217ad771275be3e40b284328dca3e6c628b429 100644 --- a/doc/README.md +++ b/doc/README.md @@ -8,6 +8,10 @@ Better than all, try it following [quickstart.md](./quickstart.md "The quickstar Base configuration file for inventory.py and play.py utilities is here : [paquerette_utils.conf.yml](./paquerette_utils.conf.yml "The best configuration file you ever read") and should be copied when easily filled with your host list into the install directory -Base server configuration file is here : [host_template.yml](./host_template.yml "The template of the century") +Host configuration file is here : [host_template.yml](./host_template.yml "The template of the century") -Sample for production server inventory is here : [hosts.prod](./hosts.prod "The ultimate revelation") \ No newline at end of file +Base server configuration file : [base_server_template.yml]() to be copied in group_vars/base_server/baser_serve.yml + +Sample for production server inventory is here : [hosts.prod](./hosts.prod "The ultimate revelation") + +If you want to user ansible paquerette roles in your own project follows [how to setup your own project](./project_installation/readme.md) \ No newline at end of file diff --git a/doc/hosts.prod b/doc/hosts.prod index 4368140ef747e1f6ef6d37f7ff2540f4802cf2d0..fbd76f05529601ec9c175ed1335add753ed4119a 100644 --- a/doc/hosts.prod +++ b/doc/hosts.prod @@ -2,11 +2,24 @@ ### hosts prodhost1 hostvar=... prodhost2 hostvar=... +prodhost3 hostvar=... testhost1 hostvar=... ### groups +[secured] +prodhost1 +prodhost2 +prodhost3 + +[application_servers] +prodhost1 +prodhost3 + +[large_hosts] +prodhost3 + [test] testhost1 @@ -22,4 +35,11 @@ prod test [secret:children] -base_server \ No newline at end of file +base_server + +[all:vars] +# +# default for new machines +# +ansible_user=.... +ansible_ssh_private_key_file=.......... diff --git a/project_installation/readme.md b/doc/project_installation/readme.md similarity index 100% rename from project_installation/readme.md rename to doc/project_installation/readme.md diff --git a/roles/_app_monit/README.md b/roles/_app_monit/README.md index cee3710bf66beda325f18acf34a783620776105b..179fbacc7890662f346bde860e445ab3d7e9269f 100644 --- a/roles/_app_monit/README.md +++ b/roles/_app_monit/README.md @@ -5,6 +5,16 @@ - monit_expect: expected string expression in http response (regular expression) - monit_timeout : **3** +## monitoring a data volume + +When an application instance uses its own data volume you may define + +- **volume_name** is the volume to be monitored +- **volume_path** with default to "/mnt/{{ volume_name }} + +Usage alert threshold is set to **monit_system_data_partition_usage** defined in base_server_template.yml + + uses - [monit](https://mmonit.com/documentation/) - http_check utility (see templates) diff --git a/roles/_app_monit/defaults/main.yml b/roles/_app_monit/defaults/main.yml index 83f26431c7ab030f9f011382d7bfba803d994220..d1356233e8bea6ec0529356aed59031536b299a6 100644 --- a/roles/_app_monit/defaults/main.yml +++ b/roles/_app_monit/defaults/main.yml @@ -7,4 +7,6 @@ monit_timeout: 3 # default status 200 monit_status: "" + # default volumes + volume_path: "/mnt/{{ volume_name | default()}}" diff --git a/roles/_app_monit/handlers/main.yml b/roles/_app_monit/handlers/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..d1da6932c3a5cac1c02a1b8ac21714a7d589d44e --- /dev/null +++ b/roles/_app_monit/handlers/main.yml @@ -0,0 +1,6 @@ +--- + +- name: reload monit app monit + service: name=monit state=reloaded + tags: + - always \ No newline at end of file diff --git a/roles/_app_monit/tasks/install.yml b/roles/_app_monit/tasks/install.yml index 616a868e0a2c859dbdec7839598f4322124b1bc6..e0b3db7affcfeab2b2f3364116623bc5f79e9852 100644 --- a/roles/_app_monit/tasks/install.yml +++ b/roles/_app_monit/tasks/install.yml @@ -10,13 +10,10 @@ src: "http_check.py.j2" dest: "{{ base_prod_options }}/http_check/http_check.py" mode: "755" + notify: reload monit app monit - name: "monitoring configuration for {{ app_domain }}" template: src: "app_monit.j2" dest: "/etc/monit/conf.d/{{ app_instance_id }}.conf" - register: monit_conf - - - name: reload monit - service: name=monit state=reloaded - when: monit_conf.changed + notify: reload monit app monit diff --git a/roles/_app_monit/tasks/main.yml b/roles/_app_monit/tasks/main.yml index 50001f2b2923eec636ccb0add3f58a7b7b531eeb..197ce89e5e0a44f24154393a0dd8127e91a53b81 100644 --- a/roles/_app_monit/tasks/main.yml +++ b/roles/_app_monit/tasks/main.yml @@ -7,3 +7,9 @@ - import_tasks: uninstall.yml when: app_run == 'uninstall' tags: _app_monit + +- name: ensure monit is started + service: + name: monit + state: started + tags: _app_monit diff --git a/roles/_app_monit/tasks/uninstall.yml b/roles/_app_monit/tasks/uninstall.yml index 3a2195e6849642fa6d153b822f5dd18f54338269..c0c645497dde014e33f45e90a8760484132adb5f 100644 --- a/roles/_app_monit/tasks/uninstall.yml +++ b/roles/_app_monit/tasks/uninstall.yml @@ -4,8 +4,4 @@ file: path: "/etc/monit/conf.d/{{ app_instance_id }}.conf" state: absent - register: monit_conf - - - name: reload monit - service: name=monit state=reloaded - when: monit_conf.changed + notify: reload monit _app_monit diff --git a/roles/_app_monit/templates/app_monit.j2 b/roles/_app_monit/templates/app_monit.j2 index bb1e552800e7c450109f478e4ba5cf7cc684d240..4991b22c5650f2db80a399f966c1f3cf8b82aabd 100644 --- a/roles/_app_monit/templates/app_monit.j2 +++ b/roles/_app_monit/templates/app_monit.j2 @@ -6,3 +6,8 @@ with path "{{ base_prod_options }}/http_check/http_check.py -t {{ monit_timeout if status != 0 for 3 cycles then alert +{% if volume_name | default() %} +check filesystem {{ volume_name }} with path {{ volume_path }} + if space usage > {{ monit_system_data_partition_usage }}% for 5 times within 15 cycles then alert + if changed fsflags then alert +{% endif %} \ No newline at end of file diff --git a/roles/base_server/defaults/main.yml b/roles/base_server/defaults/main.yml index e028a9bf222c555c88a60f0c8f68f5e3a89c1676..0b427b71732d82c42a6c62a5c0c5a32f2c721e9d 100644 --- a/roles/base_server/defaults/main.yml +++ b/roles/base_server/defaults/main.yml @@ -12,3 +12,12 @@ _monit_ssl_option: "tls" monit_system_loadavg_1min: 2 monit_system_loadavg_5min: 1.5 + + +# system monitoring defaults +# when % raised then alert +monit_system_cpu_usage: 95 +monit_system_memory_usage: 95 +monit_system_swap_usage: 90 +monit_system_root_partition_usage: 80 +monit_system_data_partition_usage: 90