-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added documentation for dependency objects * added module for object depenendy * added tests for module dependency Closes #20 Co-authored-by: Thilo W <mkayontour@gmail.com>
- Loading branch information
1 parent
3d6ca67
commit 3fa7aa7
Showing
5 changed files
with
92 additions
and
1 deletion.
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
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,17 @@ | ||
def test_icinga2_object_host(host): | ||
i2_file = host.file("/etc/icinga2/zones.d/main/dependencies.conf") | ||
print(i2_file.content_string) | ||
assert i2_file.is_file | ||
assert i2_file.contains('apply Dependency "dependency-test" to Host {') | ||
assert i2_file.contains('disable_checks = true') | ||
assert i2_file.contains('states = [ Up, ]\n') | ||
assert i2_file.contains('parent_host_name = "agent.localdomain"') | ||
assert i2_file.contains('assign where host.name == "test.localdomain"') | ||
if host.system_info.distribution == 'centos': | ||
assert i2_file.user == "icinga" | ||
assert i2_file.group == "icinga" | ||
assert i2_file.mode == 0o644 | ||
if host.system_info.distribution == 'debian': | ||
assert i2_file.user == "nagios" | ||
assert i2_file.group == "nagios" | ||
assert i2_file.mode == 0o644 |
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,44 @@ | ||
#!/usr/bin/python | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
def main(): | ||
module = AnsibleModule( | ||
supports_check_mode=True, | ||
argument_spec = dict( | ||
state = dict(default='present', choices=['present', 'absent']), | ||
name = dict(required=True), | ||
order = dict(default=10, type='int'), | ||
file = dict(required=True, type='str'), | ||
template = dict(default=False, type='bool'), | ||
imports = dict(default=list(), type='list', elements='str'), | ||
apply = dict(default=False, type='bool'), | ||
apply_target = dict(type='str'), | ||
parent_host_name = dict(type='str'), | ||
parent_service_name = dict(type='str'), | ||
child_host_name = dict(type='str'), | ||
child_service_name = dict(type='str'), | ||
disable_checks = dict(type='bool'), | ||
disable_notifications = dict(type='bool'), | ||
ignore_soft_states = dict(type='bool'), | ||
period = dict(type='str'), | ||
states = dict(type='list', elements='str'), | ||
assign = dict(default=list(), type='list', elements='str'), | ||
ignore = dict(default=list(), type='list', elements='str'), | ||
) | ||
) | ||
|
||
args = module.params | ||
name = args.pop('name') | ||
order = args.pop('order') | ||
state = args.pop('state') | ||
file = args.pop('file') | ||
template = args.pop('template') | ||
imports = args.pop('imports') | ||
apply = args.pop('apply') | ||
apply_target = args.pop('apply_target') | ||
|
||
module.exit_json(changed=False, args=args, name=name, order=str(order), state=state, file=file, template=template, imports=imports, apply=apply, apply_target=apply_target) | ||
|
||
if __name__ == '__main__': | ||
main() |
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