From 6fc3c95d7f22bb6d2ce016fe08d2a83f776d8b02 Mon Sep 17 00:00:00 2001 From: "Philip (a-0)" <@ph:a-0.me> Date: Wed, 7 Sep 2022 14:27:23 +0200 Subject: [PATCH] Take configuration as python/yaml object instead of file content --- README.md | 2 +- example_playbook_fromsource.yml | 8 +++++++- example_playbook_prebuilt.yml | 8 +++++++- tasks/main.yml | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d11eebb..4825d2e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ See example playbooks for configuration samples. Required variables: - `matrixmailer_version`: Pinned version of matrixmailer to install, e.g. "0.1.0" - `matrixmailer_build`: Either "from_source" if you want to build it yourself, or the build target for prebuilt binaries, like "x86_64-unknown-linux-musl" -- `matrixmailer_config`: Yaml content of the configuration file. You may want to consider importing it from a file rather than putting the file content directly into the playbook. +- `matrixmailer_config`: Python/Yaml object of the matrixmailer configuration. Will be interpreted by the role and written to the configuration file formatted as yaml. Optional variables: - `matrixmailer_git_repo`: Only used when self-building the binary. Allows you to specify any URL a matrixmailer git repository can be pulled from. diff --git a/example_playbook_fromsource.yml b/example_playbook_fromsource.yml index dcf9b96..44c8261 100644 --- a/example_playbook_fromsource.yml +++ b/example_playbook_fromsource.yml @@ -4,6 +4,12 @@ vars: - matrixmailer_version: "0.1.0" - matrixmailer_build: "from_source" - - matrixmailer_config: "{{ lookup("file", "path/to/config/file/template.yaml") }}" + # This is a very basic matrixmailer configuration. For more details, consult the matrixmailer documentation. + - matrixmailer_config: + clients: + - mxid: "@yourbot:example.com" + password: "p@ssw0rd" + mappings: + - room: "!idoftheroomyoucreatedbefore:example.com" # The following option can be left out to use the default git repository - matrixmailer_git_repo: "https://git.myorg.com/user/matrixmailer.git" \ No newline at end of file diff --git a/example_playbook_prebuilt.yml b/example_playbook_prebuilt.yml index bc28fed..d4d2904 100644 --- a/example_playbook_prebuilt.yml +++ b/example_playbook_prebuilt.yml @@ -4,4 +4,10 @@ vars: - matrixmailer_version: "0.1.0" - matrixmailer_build: "x86_64-unknown-linux-musl" - - matrixmailer_config: "{{ lookup("file", "path/to/config/file/template.yaml") }}" \ No newline at end of file + # This is a very basic matrixmailer configuration. For more details, consult the matrixmailer documentation. + - matrixmailer_config: + clients: + - mxid: "@yourbot:example.com" + password: "p@ssw0rd" + mappings: + - room: "!idoftheroomyoucreatedbefore:example.com" \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index efc0c84..9c26d95 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -93,7 +93,7 @@ - name: Set config file copy: - content: "{{ matrixmailer_config }}" + content: "{{ matrixmailer_config | to_nice_yaml }}" dest: "{{ matrixmailer_config_dir }}/config.yaml" owner: "{{ matrixmailer_system_user }}" group: "{{ matrixmailer_system_group }}"