mKeRix / room-assistant

Presence tracking and more for automation on the room-level
https://www.room-assistant.io
MIT License
1.27k stars 122 forks source link

Shared configuration within a cluster #261

Open bensuffolk opened 4 years ago

bensuffolk commented 4 years ago

Is your feature request related to a problem? Please describe. It should be possible to have remote servers read the configuration from a master server (for instance the one running as a HASS Add On).

Describe the solution you'd like If I want to add (or remove) a device for tracking I would like to do this one one place only. Namely on the Add On configuration page within HASS Supervisor. Once the devices have been added here, they should automatically propagate to all other instances in the cluster without having to update every other instance by hand

Describe alternatives you've considered Obviously I could install something like ansible and have remote configuration of all the instances, but thats not as convenient, and not really suitable for the target audience of HASS and home automation.

Additional context

Possible implementation idea would be to have one instance marked as config master and any other instance can request a checksum of the configuration (to see if there are any changes) and can request the actual configuration from the config master.

Whenever an instance joins the cluster it can query who the config master is (this could be different from the cluster leader), and can then request the checksum / configuration.

If the configuration is changed the config master would restart, so whenever the master joins a cluster it should publish the checksum, allowing any other member of the cluster to verify if they need to download new config, and if so they can request the config.

The configuration would mainly be used for the devices, but would also be of use for the integrations and other settings. In order to make sure configuration for a specific instance does not get overwritten (e.g. cluster weight) you could either have a local config file that takes precedence, or a per host section based on the instanceName in the master config file that is used on that instance only.

mKeRix commented 4 years ago

Originally I decided to go with ansible since this lets a specialized tool handle the deployment and config management instead of complicating the room-assistant codebase. You raise a good point here though - ansible is a tool that won't really be used much by people without much IT knowledge. I guess it would be a good idea to tackle this feature requests with the aim of making room-assistant more accessible to everyone in the future.

Thanks for the feature request!

bemble commented 2 years ago

Hi, any news about this feature?

I just installed my first cluster with the idea of "one to rule them all": a leader on a server, its only aim is to have the reference configuration (devices, home assistant configuration etc.), and other nodes on rpis using docker with only few lines in the configuration.

By the way, great job, thanks for room-assistan, it works great!

LostSoulfly commented 2 years ago

I agree, this would make things much more accessible. I don't have any experience with Ansible (or time to learn it, truthfully). While only a minor annoyance to ssh into each pi zero, some people might get lost or frustrated adding new devices to each pi.

As room-assistant already sends a list of peers, it shouldn't bee too complicated to just share the allowlist contents if a config switch exists under cluster:.

You could also probably avoid writing the logic to do this into room-assistant by making a setup script that does everything needed to install with a simple menu with options to pull allowlists from the current cluster leader, perhaps as an API route and have it write directly into the local.yaml?

Setup bash script menu example

1. Setup (run through the commands outlines in [the setup docs](url))
2. Repair
3. Sync allowlist from master (could even ask to input IP:port to keep it super simple if peerAddresses is not defined)