Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch Ansible Setup #369

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

thepsalmist
Copy link
Contributor

@thepsalmist thepsalmist commented Mar 10, 2025

This PR introduces Ansible playbooks and roles for deploying ad managing an Elasticsearch cluster.
This builds off from the discussion on #366 and the draft at #367

philbudne and others added 30 commits February 23, 2025 00:03
Introduce secrets managememt using ansible-vault
@thepsalmist thepsalmist marked this pull request as ready for review March 11, 2025 15:43
@thepsalmist thepsalmist changed the title Draft ES Ansible Elasticsearch Ansible Setup Mar 11, 2025
Copy link

@DavidTheProgrammer DavidTheProgrammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I've left a few comments on the general structure and I have a couple of questions about the role we're using, is it something we've hand-rolled or it's available on Ansible Galaxy? It seems to be environment dependent with the vars files and that is setting off some flags for me as roles should not be environment dependent. Is there any reason we can't use a 3rd party installation modules for ES 8+ Like this one: https://galaxy.ansible.com/ui/standalone/roles/geerlingguy/elasticsearch/install/ ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory ideally should only contain variables shared by specific groups and since we don't have a group named "vault", I'd recommend we move this one level up to the inventory level. The rationale is that this is the vault used for this particular inventory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have found the alternative directory layout located in the Ansible best practices that seperates the inventories based on environment to work quite well in the past. Reduces filters needed and allows us to actually use all group for things like agent installation that needs to happen on all hosts while only affecting specific environments.

https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html#alternative-directory-layout

hosts: elasticsearch
vars_files:
- ../inventories/group_vars/vault.yml
- ../roles/elasticsearch/vars/{{ env | default('production') }}.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we default to staging? I think that's a safer default.

- ../roles/elasticsearch/vars/{{ env | default('production') }}.yml
become: true

roles:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use include_role instead of the traditional roles: section

Following this article we should prefer include_roles instead of the roles section. I think it's okay.

https://www.ansiblejunky.com/blog/ansible-101-standards/#playbooks

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these to a standalone role and include it in this playbook instead of having the tasks written directly? This also comes from the recommendations in the Ansible 101 article.

https://www.ansiblejunky.com/blog/ansible-101-standards/#playbooks

@philbudne
Copy link
Contributor

philbudne commented Mar 14, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate elasticsearch configuration using ansible
3 participants