hassio-addons / addon-mqtt

MQTT Server & Web client - Home Assistant Community Add-ons
https://addons.community
MIT License
35 stars 15 forks source link

Will not read secret variables containing dots (.) #20

Closed djmixman closed 5 years ago

djmixman commented 5 years ago

Problem/Motivation

When using the the !secret option the addon will not load the variables containing dots.

My convention for storing items in secrets as followed:

<path_or_service>.<desc>.<variable> or components.weather.darksky.api_key

or in this case:

system.addons.mqtt.admin_username system.addons.mqtt.admin_password

Expected behavior

The expected behavior would be to read in the variables regardless of the chars used.

Actual behavior

Currently the add-on will not load due to the requested variable containing a "." and terminates with an error. See attached log below.

Steps to reproduce

Add a "." into a variable name and try to restart MQTT.

Proposed changes

Allow variables to contain dots or most, if not all, standard characters.

Log

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Hass.io Add-on: MQTT Server & Web client v0.3.0
 Mosquitto MQTT Server bundled with Hivemq's web client
 From: Community Hass.io Add-ons
 By: Franck Nijhof <frenck@addons.community>
-----------------------------------------------------------
 armhf / null / HA 0.84.6 / SU 141 / stable
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] 02-updates.sh: executing... 
INFO: You are running the latest version of this add-on
[cont-init.d] 02-updates.sh: exited 0.
[cont-init.d] 10-requirements.sh: executing... 
ERROR: Secret system.addons.mqtt.admin_username not found in secrets.yaml file.
FATAL: Missing username for MQTT User
[cont-init.d] 10-requirements.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.

 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] syncing disks.
[s6-finish] sending all processes the TERM signal.
addons-assistant[bot] commented 5 years ago

:wave: Thanks for opening your first issue here! If you're reporting a :bug: bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be usefull.

vdmeulennld commented 5 years ago

Your configuration.yaml file should contain:

# Example configuration.yaml entry mqtt webserver mqtt: broker: a0d7b954-mqtt username: !secret mqtt_username password: !secret mqtt_password client_id: home-assistant

Then there must be a secrets.yaml file in the same directory.

This file must contain:

mqtt_username: djmixman mqtt_password: mistermixer

The rule for the configuration.yaml file with !secret prefix_name is that !secret must be not typed in the secrets.yaml file.

So in the secrets.yaml file only use the prefix_name: characters must be used.

djmixman commented 5 years ago

I use secrets a lot of places and have a pretty hefty file.

This works great:

mqtt_username: djmixman
mqtt_password: password

HOWEVER if you do this:

mqtt.username: djmixman
mqtt.password: password

It will fail with the above message in my previous post. I haven't tried any other addon's yet, I suspect they will fail as well, but im not sure. However, dot's work everywhere else.

ludeeus commented 5 years ago

They will all fail @djmixman we use the same logic

addons-assistant[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

addons-assistant[bot] commented 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.