freedomofpress / ansible-role-elk

Installs a turnkey ELK stack for log aggregation and analysis, with optional Riemann support for alerting
18 stars 13 forks source link

Set ES_HEAP_SIZE to half of system memory #17

Closed ageis closed 8 years ago

conorsch commented 8 years ago

Not bad. It breaks with low amounts of RAM though—for instance, if the host has 512MB, the output resolves to 0g. Half a gig of RAM is too little to run an ELK stack realistically, but the config should still sanity check the values. How about a two-pass approach:

  1. use set_fact to store the numeric value of the intended heapsize
  2. update the defaults file for elasticsearch if-and-only-if the newly set fact > 0; append the suffix "g" while writing to the file

In addition, the task updating the defaults file should notify the handler to restart the elasticsearch service.

conorsch commented 8 years ago

See #9 for context.

conorsch commented 8 years ago

Changes look good! Will test locally and report back.

conorsch commented 8 years ago

Refactored the var logic a bit. Odd numbers of GB for RAM weren't assigning to 50% correctly, so switched to using MB instead, which helps. Also implemented a sanity check on the upper bound of 31GB, per the ElasticSearch docs.

Reran the tests with a variety of RAM values and it's looking pretty good—let's hold off on merge until we have a serverspec test to track this new task.

conorsch commented 8 years ago

OK, added a corresponding test—let me rerun the build with various RAM amounts again and I'll report back.

conorsch commented 8 years ago

Happy with the task and tests, merging.