Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Extra configs variable from CEEMS API server #11

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roles/ceems_api_server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ceems_api_server_data_backup_interval: ""
ceems_api_server_admin_users: []
ceems_api_server_cli_args: []
ceems_api_server_env_vars: {}
ceems_api_server_extra_configs: {}
ceems_api_server_binary_install_dir: /usr/local/bin
ceems_api_server_system_group: ceems
ceems_api_server_system_user: "{{ ceems_api_server_system_group }}"
Expand Down
5 changes: 5 additions & 0 deletions roles/ceems_api_server/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ argument_specs:
- I(Advanced)
- Environment variables will be passed to CEEMS API server
type: dict
ceems_api_server_extra_configs:
description:
- I(Advanced)
- Extra configuration files for CEEMS API server. These files will be created in CEEMS API server config dir with the same name as key of the argument dict.
type: dict
4 changes: 4 additions & 0 deletions roles/ceems_api_server/molecule/alternative/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ provisioner:
- --web.max.query.period=30d
ceems_api_server_env_vars:
foo: bar
ceems_api_server_extra_configs:
tsdb_config:
web_url: http://localhost:9090
queries: {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def test_directories(host, dir):

@pytest.mark.parametrize("file", [
"/etc/systemd/system/ceems_api_server.service",
"/usr/local/bin/ceems_api_server"
"/usr/local/bin/ceems_api_server",
"/etc/ceems_api_server/config.yaml",
"/etc/ceems_api_server/tsdb_config.yaml",
])
def test_files(host, file):
f = host.file(file)
Expand Down
21 changes: 19 additions & 2 deletions roles/ceems_api_server/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
dest: /etc/systemd/system/ceems_api_server.service
owner: root
group: root
mode: "0640"
mode: u+rw,g+r,o-rwX
notify: restart ceems_api_server

- name: Create ceems_api_server config directory
Expand All @@ -31,7 +31,24 @@
dest: /etc/ceems_api_server/config.yaml
owner: "{{ ceems_api_server_system_user }}"
group: "{{ ceems_api_server_system_group }}"
mode: "0640"
mode: u+rw,g+r,o-rwX
notify: restart ceems_api_server

- name: Create extra config files
ansible.builtin.copy:
dest: "/etc/ceems_api_server/{{ item.key }}.yaml"
owner: "{{ ceems_api_server_system_user }}"
group: "{{ ceems_api_server_system_group }}"
mode: u+rw,g+r,o-rwX
content: |
#
# Ansible managed: Do NOT edit this file manually!
#
---

{{ item.value | to_nice_yaml }}
when: ceems_api_server_extra_configs | length > 0
loop: "{{ ceems_api_server_extra_configs | dict2items }}"
notify: restart ceems_api_server

- name: Make the ceems_api_server data directory
Expand Down
Loading