Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ The following variables are avaible:
- Default: `/tmp/ece-support-diagnostics`
- `ece_runner_id`: Assigns an arbitrary ID to the host (runner) that you are installing Elastic Cloud Enterprise on
- Default: `ansible_default_ipv4.address`
- `allocator_tags`: If your allocators require allocator tags, you can set this variable on the allocator hosts
- Default: no allocator tags

If more hosts should join an Elastic Cloud Enterpise installation when a primary host was already installed previously there are two more variables that are required:
- `primary_hostname`: The (reachable) hostname of the primary host
Expand Down Expand Up @@ -165,6 +167,20 @@ all:
availability_zone: zone-3
```

If you rely on allocator tags you can add them to each of the allocator hosts above - it could look like this:
```yaml
allocator:
hosts:
host4:
availability_zone: zone-1
allocator_tags: "i3en:true"
host5:
availability_zone: zone-2
allocator_tags: "i3en:true"
host6:
availability_zone: zone-3
allocator_tags: "i3en:true"
```
### Adding hosts to an existing installation

Assuming you already have an existing installation of Elastic Cloud Enterprise and you want to add more allocators to it you need to specify two additional variables:
Expand Down
11 changes: 10 additions & 1 deletion tasks/ece-bootstrap/secondary/install_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@
body: '{ "persistent": false, "roles": {{ ece_roles }} }'
register: roles_token

- name: Execute installation
- name: Execute installation - no allocator-tags
shell: /home/elastic/elastic-cloud-enterprise.sh --coordinator-host {{ primary_hostname }} --roles-token '{{ roles_token.json.token }}' --roles '{{ ece_roles | join(',') }}' --availability-zone {{ availability_zone }} --cloud-enterprise-version {{ ece_version }} --docker-registry {{ ece_docker_registry }} --ece-docker-repository {{ ece_docker_repository }} --host-storage-path {{ data_dir }}/elastic --memory-settings '{{ memory_settings }}' --runner-id {{ ece_runner_id }}
become: yes
become_method: sudo
become_user: elastic
register: installation
when: allocator_tags is undefined

- name: Execute installation - with allocator-tags
shell: /home/elastic/elastic-cloud-enterprise.sh --coordinator-host {{ primary_hostname }} --roles-token '{{ roles_token.json.token }}' --roles '{{ ece_roles | join(',') }}' --availability-zone {{ availability_zone }} --cloud-enterprise-version {{ ece_version }} --docker-registry {{ ece_docker_registry }} --ece-docker-repository {{ ece_docker_repository }} --host-storage-path {{ data_dir }}/elastic --memory-settings '{{ memory_settings }}' --runner-id {{ ece_runner_id }} --allocator-tags {{ allocator_tags }}
become: yes
become_method: sudo
become_user: elastic
register: installation
when: allocator_tags is defined
Comment on lines +22 to +36
Copy link
Contributor

@m-a-leclercq m-a-leclercq Apr 4, 2022

Choose a reason for hiding this comment

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

You should be able to inline that with jinja conditionals, it would avoid having two tasks for the same thing with only one option differing.

I have not tested that code but maybe you could, see if that works?

Suggested change
- name: Execute installation - no allocator-tags
shell: /home/elastic/elastic-cloud-enterprise.sh --coordinator-host {{ primary_hostname }} --roles-token '{{ roles_token.json.token }}' --roles '{{ ece_roles | join(',') }}' --availability-zone {{ availability_zone }} --cloud-enterprise-version {{ ece_version }} --docker-registry {{ ece_docker_registry }} --ece-docker-repository {{ ece_docker_repository }} --host-storage-path {{ data_dir }}/elastic --memory-settings '{{ memory_settings }}' --runner-id {{ ece_runner_id }}
become: yes
become_method: sudo
become_user: elastic
register: installation
when: allocator_tags is undefined
- name: Execute installation - with allocator-tags
shell: /home/elastic/elastic-cloud-enterprise.sh --coordinator-host {{ primary_hostname }} --roles-token '{{ roles_token.json.token }}' --roles '{{ ece_roles | join(',') }}' --availability-zone {{ availability_zone }} --cloud-enterprise-version {{ ece_version }} --docker-registry {{ ece_docker_registry }} --ece-docker-repository {{ ece_docker_repository }} --host-storage-path {{ data_dir }}/elastic --memory-settings '{{ memory_settings }}' --runner-id {{ ece_runner_id }} --allocator-tags {{ allocator_tags }}
become: yes
become_method: sudo
become_user: elastic
register: installation
when: allocator_tags is defined
- name: Execute installation
shell: "/home/elastic/elastic-cloud-enterprise.sh --coordinator-host {{ primary_hostname }} --roles-token '{{ roles_token.json.token }}' --roles '{{ ece_roles | join(',') }}' --availability-zone {{ availability_zone }} --cloud-enterprise-version {{ ece_version }} --docker-registry {{ ece_docker_registry }} --ece-docker-repository {{ ece_docker_repository }} --host-storage-path {{ data_dir }}/elastic --memory-settings '{{ memory_settings }}' --runner-id {{ ece_runner_id }}{% if allocator_tags is defined %} --allocator-tags {{ allocator_tags }}{% endif %}"
become: yes
become_method: sudo
become_user: elastic
register: installation

Just my personal review as I am not maintaining that repo but this is what I would do 😄

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the review! I didn't realise that you can review without being a maintainer. That's nice.

I was focused on the YAML-stuff, but you are right of course: Utilising Jinja2 to do logic as well is the way to go.
I can probably use that make sure that allocator tags get added to allocators only. This was my original concern: If this quick hack would be accepted as-is or a check for the host being an allocator was needed. I expected some feedback on that question, but didn't get any.

So instead of just accepting your suggestion, I will try to fix both problems in one go. I hope to find time to work on this soon.

Copy link
Contributor

@m-a-leclercq m-a-leclercq Apr 21, 2022

Choose a reason for hiding this comment

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

You're welcome.

I did another PR that is up to date with the master branch command and reworked the syntax for better readability. It can be found here https://github.com/elastic/ansible-elastic-cloud-enterprise/pull/151/files You shoud be able to jinja your way to an allocator tags command from there.

I agree with you on the control part but I think it should be expanded to the whole command. Since there is no check being done via the API, you can also add garbage in the --role part of the command and it can have disastrous consequences (I tried and had a really bad time, I couldn't remove the newly added machine from the cluster without shutting down the machine and removing it forcefully).