-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of using environment variables for configuration, this switches to using configuration files for the configuration of the lobby bots. This ensures that that sensitive configuration values aren't visible in the process list anymore. Deploying this requires adjusting the lobby configuration files to account for the changed key names. An example for that is included in the changes to `config-lobby-vagrant.yml` as part of this commit.
- Loading branch information
Showing
7 changed files
with
89 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
|
||
from ansible.errors import AnsibleFilterTypeError | ||
|
||
|
||
class FilterModule: | ||
|
||
@classmethod | ||
def convert_value(cls, value): | ||
if isinstance(value, (list, tuple)): | ||
l = [cls.convert_value(i) for i in value] | ||
return "[ " + ", ".join(l) + " ]" | ||
elif isinstance(value, dict): | ||
l = [f"{k} = {cls.convert_value(v)}" for k, v in value.items()] | ||
return "{ " + ", ".join(l) + " }" | ||
elif isinstance(value, str): | ||
return f"\"{value}\"" | ||
elif isinstance(value, bool): | ||
return "true" if value else "false" | ||
else: | ||
return str(value) | ||
|
||
@staticmethod | ||
def to_toml(value): | ||
"""Convert a dictionary to TOML. | ||
This is a very naive, but good enough Jinja filter to convert a | ||
dictionary to TOML. | ||
Using a library like `tomli-w` would be more elegant, but would | ||
add an additional dependency for being able to run the Ansible | ||
code. | ||
""" | ||
if not isinstance(value, dict): | ||
raise AnsibleFilterTypeError("Data to be converted to TOML needs to be a dictionary, " | ||
"got %s instead" % type(value)) | ||
|
||
new_value = "" | ||
for key, value2 in value.items(): | ||
converted_value = FilterModule.convert_value(value2) | ||
new_value += f"{key} = {converted_value}" + os.linesep | ||
return new_value | ||
|
||
def filters(self): | ||
return { | ||
'to_toml': self.to_toml | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters