Skip to content

Commit

Permalink
add icinga_deploy_* to action_group and test it (#214)
Browse files Browse the repository at this point in the history
* add icinga_deploy_* to action_group and test it

* fix error with no existing deployment

* linting

* Update tests/integration/targets/defaults_test/defaults_test.yml

Co-authored-by: schurzi <[email protected]>

---------

Co-authored-by: schurzi <[email protected]>
  • Loading branch information
rndmh3ro and schurzi authored Jun 2, 2023
1 parent 80fc81c commit 5c0bb9f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ After making code changes, please run the linters and fix all errors:
> tox -elinters
```

### Updating the tests and examples
### Updating the tests and examples and runtime

If you add new features or arguments to the existing modules, please add them to the examples in the module itself.
The integration tests and examples in our documentation are then generated from the module-examples.
Expand All @@ -35,6 +35,7 @@ Download example:
> sudo wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 -O /usr/bin/yq ; sudo chmod 755 /usr/bin/yq
```

If you add a new module, be sure to add it to the `action_groups` in the `meta/runtime.yml`-file.

### Integration tests with docker

Expand Down
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ action_groups:
- icinga_command_info
- icinga_command_template
- icinga_command_template_info
- icinga_deploy
- icinga_deploy_info
- icinga_endpoint
- icinga_endpoint_info
- icinga_host
Expand Down
7 changes: 6 additions & 1 deletion plugins/modules/icinga_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def main():

# get the current deployment status
icinga_deploy_status = Icinga2APIObject(module=module, path="/config/deployment-status", data=[])
active_deployment = icinga_deploy_status.query_deployment()["data"]["active_configuration"]["config"]

# if there is no existing deployment (e.g. on a new instance), there is no config object
if "config" in icinga_deploy_status.query_deployment()["data"]["active_configuration"]:
active_deployment = icinga_deploy_status.query_deployment()["data"]["active_configuration"]["config"]
else:
active_deployment = ""

# execute the deployment
icinga_deployment = Icinga2APIObject(module=module, path="/config/deploy", data=[])
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/targets/defaults_test/defaults_test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
---
- name: provide module defaults
- name: Provide module defaults
hosts: localhost
module_defaults:
group/t_systems_mms.icinga_director.icinga:
url: "{{ icinga_url }}"
url_username: "{{ icinga_user }}"
url_password: "{{ icinga_pass }}"
handlers:
- name: Deploy the icinga config
t_systems_mms.icinga_director.icinga_deploy:
listen: config_deploy
tasks:
- name: Create command
t_systems_mms.icinga_director.icinga_command:
state: present
command: "true"
command_type: "PluginCheck"
object_name: defaults_test
notify:
- config_deploy

- name: Flush handlers
meta: flush_handlers

0 comments on commit 5c0bb9f

Please sign in to comment.