Take configuration as python/yaml object instead of file content

This commit is contained in:
Philip (a-0) 2022-09-07 14:27:23 +02:00
parent 318029b9a9
commit 6fc3c95d7f
4 changed files with 16 additions and 4 deletions

View file

@ -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.

View file

@ -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"

View file

@ -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") }}"
# 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"

View file

@ -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 }}"