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

New module icinga2 service #58108

Open
wants to merge 8 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@knaapjvd
Copy link

commented Jun 20, 2019

SUMMARY

This new module compliments the icinga2_host module, allowing for service object provisioning for hosts objects

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

icinga2_service

ADDITIONAL INFORMATION

EXAMPLE =

- name: Add a service to a host to icinga
  icinga2_service:
    url: "https://icinga2.example.com"
    url_username: "ansible"
    url_password: "a_secret"
    state: present
    name: "{{ ansible_fqdn }}!nrpe"
    display_name: "NRPE"
    check_command: "nrpe"
    variables:
        nrpe_port: "5667"

- name: Same service but with host/service
  icinga2_service:
    url: "https://icinga2.example.com"
    url_username: "ansible"
    url_password: "a_secret"
    state: present
    host: "{{ ansible_fqdn }}"
    service: "nrpe"
    display_name: "NRPE"
    check_command: "nrpe"
    variables:
        nrpe_port: "5667"

RETURN =

name:
    description: The name used to create, modify or delete the service
    type: string
    returned: always
data:
    description: The data structure used for create, modify or delete of the service
    type: dict
    returned: always

knaapjvd added some commits Jun 20, 2019

Manage a service for a host in Icinga2
Re-used code from icinga2_host module
This module compliments the icinga2_host module, allowing for service object provisioning for hosts objects
Update icinga2_service.py
Guessing value for `version_added`
@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

The test ansible-test sanity --test pylint [explain] failed with 15 errors:

lib/ansible/modules/monitoring/icinga2_service.py:239:14: bad-whitespace No space allowed before bracket def flat_dict (aDict):
               ^
lib/ansible/modules/monitoring/icinga2_service.py:243:15: bad-whitespace No space allowed before bracket        if type (value) is types.DictType:
                ^
lib/ansible/modules/monitoring/icinga2_service.py:244:25: bad-whitespace No space allowed before bracket          ret = flat_dict (value)
                          ^
lib/ansible/modules/monitoring/icinga2_service.py:256:16: bad-whitespace No space allowed before bracket def expand_flat (aDict):
                 ^
lib/ansible/modules/monitoring/icinga2_service.py:363:15: bad-whitespace Exactly one space required around assignment         ch_data={
                ^
lib/ansible/modules/monitoring/icinga2_service.py:395:40: bad-whitespace Exactly one space required after comma         check_command=dict(required=True,default=None),
                                         ^
lib/ansible/modules/monitoring/icinga2_service.py:442:11: bad-whitespace Exactly one space required around assignment     cascade=module.params["cascade"]
            ^
lib/ansible/modules/monitoring/icinga2_service.py:471:109: bad-whitespace No space allowed before bracket               'command_endpoint', 'notes', 'notes_url', 'action_url', 'image_icon', 'image_icon_alt', 'zone' ]
                                                                                                              ^
lib/ansible/modules/monitoring/icinga2_service.py:474:28: bad-whitespace Exactly one space required around assignment             data['attrs'][x]=module.params[x]
                             ^
lib/ansible/modules/monitoring/icinga2_service.py:493:106: bad-whitespace Exactly one space required after comma                         module.fail_json(msg="Caught return code [%i] deleting service: %s" % (ret['code'],ret['data']))
                                                                                                           ^
lib/ansible/modules/monitoring/icinga2_service.py:508:119: bad-whitespace Exactly one space required after comma                                 module.fail_json(msg="Caught return code [%i] forcing service check: %s" % (ret['code'],ret['data']))
                                                                                                                        ^
lib/ansible/modules/monitoring/icinga2_service.py:510:107: bad-whitespace Exactly one space required after comma                         module.fail_json(msg="Caught return code [%i] modifying service: %s" % (ret['code'],ret['data']))
                                                                                                            ^
lib/ansible/modules/monitoring/icinga2_service.py:520:46: bad-whitespace No space allowed before bracket                     data['attrs'] = flat_dict (data['attrs'])
                                               ^
lib/ansible/modules/monitoring/icinga2_service.py:527:119: bad-whitespace Exactly one space required after comma                                 module.fail_json(msg="Caught return code [%i] forcing service check: %s" % (ret['code'],ret['data']))
                                                                                                                        ^
lib/ansible/modules/monitoring/icinga2_service.py:529:106: bad-whitespace Exactly one space required after comma                         module.fail_json(msg="Caught return code [%i] creating service: %s" % (ret['code'],ret['data']))
                                                                                                           ^

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:3:1: SyntaxError:

The test ansible-test sanity --test line-endings [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:0:0: use "\n" for line endings instead of "\r\n"

The test ansible-test sanity --test no-dict-iteritems [explain] failed with 3 errors:

lib/ansible/modules/monitoring/icinga2_service.py:242:29: use `dict.items` or `ansible.module_utils.six.iteritems` instead of `dict.iteritems`
lib/ansible/modules/monitoring/icinga2_service.py:245:26: use `dict.items` or `ansible.module_utils.six.iteritems` instead of `dict.iteritems`
lib/ansible/modules/monitoring/icinga2_service.py:259:33: use `dict.items` or `ansible.module_utils.six.iteritems` instead of `dict.iteritems`

The test ansible-test sanity --test no-smart-quotes [explain] failed with 2 errors:

lib/ansible/modules/monitoring/icinga2_service.py:120:69: use ASCII quotes `'` and `"` instead of Unicode quotes
lib/ansible/modules/monitoring/icinga2_service.py:156:84: use ASCII quotes `'` and `"` instead of Unicode quotes

The test ansible-test sanity --test pep8 [explain] failed with 34 errors:

lib/ansible/modules/monitoring/icinga2_service.py:239:14: E211 whitespace before '('
lib/ansible/modules/monitoring/icinga2_service.py:240:3: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:240:18: E721 do not compare types, use 'isinstance()'
lib/ansible/modules/monitoring/icinga2_service.py:243:8: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:243:15: E211 whitespace before '('
lib/ansible/modules/monitoring/icinga2_service.py:243:24: E721 do not compare types, use 'isinstance()'
lib/ansible/modules/monitoring/icinga2_service.py:244:10: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:244:25: E211 whitespace before '('
lib/ansible/modules/monitoring/icinga2_service.py:245:10: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:246:12: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:246:20: E226 missing whitespace around arithmetic operator
lib/ansible/modules/monitoring/icinga2_service.py:246:24: E226 missing whitespace around arithmetic operator
lib/ansible/modules/monitoring/icinga2_service.py:247:8: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:248:10: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:250:3: E111 indentation is not a multiple of four
lib/ansible/modules/monitoring/icinga2_service.py:256:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/monitoring/icinga2_service.py:256:16: E211 whitespace before '('
lib/ansible/modules/monitoring/icinga2_service.py:257:20: E721 do not compare types, use 'isinstance()'
lib/ansible/modules/monitoring/icinga2_service.py:260:28: E721 do not compare types, use 'isinstance()'
lib/ansible/modules/monitoring/icinga2_service.py:280:1: E302 expected 2 blank lines, found 1
lib/ansible/modules/monitoring/icinga2_service.py:363:16: E225 missing whitespace around operator
lib/ansible/modules/monitoring/icinga2_service.py:395:41: E231 missing whitespace after ','
lib/ansible/modules/monitoring/icinga2_service.py:442:12: E225 missing whitespace around operator
lib/ansible/modules/monitoring/icinga2_service.py:468:5: E265 block comment should start with '# '
lib/ansible/modules/monitoring/icinga2_service.py:470:15: E128 continuation line under-indented for visual indent
lib/ansible/modules/monitoring/icinga2_service.py:471:15: E128 continuation line under-indented for visual indent
lib/ansible/modules/monitoring/icinga2_service.py:471:109: E202 whitespace before ']'
lib/ansible/modules/monitoring/icinga2_service.py:474:29: E225 missing whitespace around operator
lib/ansible/modules/monitoring/icinga2_service.py:493:107: E231 missing whitespace after ','
lib/ansible/modules/monitoring/icinga2_service.py:508:120: E231 missing whitespace after ','
lib/ansible/modules/monitoring/icinga2_service.py:510:108: E231 missing whitespace after ','
lib/ansible/modules/monitoring/icinga2_service.py:520:46: E211 whitespace before '('
lib/ansible/modules/monitoring/icinga2_service.py:527:120: E231 missing whitespace after ','
lib/ansible/modules/monitoring/icinga2_service.py:529:107: E231 missing whitespace after ','

The test ansible-test sanity --test validate-modules [explain] failed with 32 errors:

lib/ansible/modules/monitoring/icinga2_service.py:0:0: E317 Argument 'check_command' in argument_spec is marked as required but specifies a default. Arguments with a default should not be marked as required
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E319 RETURN.name.type: not a valid value for dictionary value @ data['name']['type']. Got 'string'
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E322 Argument 'flapping_threshold' is listed in the argument_spec, but not documented in the module documentation
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E322 Argument 'http_agent' is listed in the argument_spec, but not documented in the module documentation
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E324 Argument 'http_agent' in argument_spec defines default as ('ansible-httpget') but documentation defines default as (None)
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'client_cert' in argument_spec defines type as 'path' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'client_key' in argument_spec defines type as 'path' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'http_agent' in argument_spec defines type as 'str' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'url' in argument_spec defines type as 'str' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'url_password' in argument_spec defines type as 'str' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'url_username' in argument_spec defines type as 'str' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E337 Argument 'variables' in argument_spec defines type as 'dict' but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'action_url' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'check_command' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'check_period' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'command_endpoint' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'display_name' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'event_command' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'flapping_threshold' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'host' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'image_icon' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'image_icon_alt' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'name' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'notes' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'notes_url' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'service' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'state' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'template' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'zone' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:240:0: E403 Type comparison using type() found. Use isinstance() instead
lib/ansible/modules/monitoring/icinga2_service.py:257:0: E403 Type comparison using type() found. Use isinstance() instead
lib/ansible/modules/monitoring/icinga2_service.py:260:0: E403 Type comparison using type() found. Use isinstance() instead

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 20, 2019

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/monitoring/icinga2_service.py:529:106: bad-whitespace Exactly one space required after comma                         module.fail_json(msg="Caught return code [%i] deleting service: %s" % (ret['code'],ret['data']))                                                                                                           ^
lib/ansible/modules/monitoring/icinga2_service.py:556:46: bad-whitespace No space allowed before bracket                     data['attrs'] = flat_dict (data['attrs'])                                               ^

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:421:0: KeyError: 'force'

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:421:0: KeyError: 'force'

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:421:0: KeyError: 'force'

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:421:0: KeyError: 'force'

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:421:0: KeyError: 'force'

The test ansible-test sanity --test pep8 [explain] failed with 5 errors:

lib/ansible/modules/monitoring/icinga2_service.py:504:5: E265 block comment should start with '# '
lib/ansible/modules/monitoring/icinga2_service.py:506:15: E128 continuation line under-indented for visual indent
lib/ansible/modules/monitoring/icinga2_service.py:507:15: E128 continuation line under-indented for visual indent
lib/ansible/modules/monitoring/icinga2_service.py:529:107: E231 missing whitespace after ','
lib/ansible/modules/monitoring/icinga2_service.py:556:46: E211 whitespace before '('

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:0:0: E321 Exception attempting to import module for argument_spec introspection, ''force''

click here for bot help

Joost van der Knaap added some commits Jun 21, 2019

@ansibot ansibot removed the ci_verified label Jun 21, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 21, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/monitoring/icinga2_service.py:502:5: E265 block comment should start with '# '

The test ansible-test sanity --test validate-modules [explain] failed with 6 errors:

lib/ansible/modules/monitoring/icinga2_service.py:0:0: E322 Argument 'image_icon' is listed in the argument_spec, but not documented in the module documentation
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E322 Argument 'image_icon_alt' is listed in the argument_spec, but not documented in the module documentation
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E323 Argument 'icon_image' is listed in DOCUMENTATION.options, but not accepted by the module argument_spec
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E323 Argument 'icon_image_alt' is listed in DOCUMENTATION.options, but not accepted by the module argument_spec
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'image_icon' in argument_spec uses default type ('str') but documentation doesn't define type
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E338 Argument 'image_icon_alt' in argument_spec uses default type ('str') but documentation doesn't define type

click here for bot help

@ansibot ansibot added the ci_verified label Jun 21, 2019

@ansibot ansibot removed the ci_verified label Jun 21, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 21, 2019

The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:

lib/ansible/modules/monitoring/icinga2_service.py:0:0: E322 Argument 'api_user' is listed in the argument_spec, but not documented in the module documentation
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E322 Argument 'user' is listed in the argument_spec, but not documented in the module documentation
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E323 Argument 'api_username' is listed in DOCUMENTATION.options, but not accepted by the module argument_spec
lib/ansible/modules/monitoring/icinga2_service.py:0:0: E323 Argument 'username' is listed in DOCUMENTATION.options, but not accepted by the module argument_spec

click here for bot help

@ansibot ansibot added the ci_verified label Jun 21, 2019

@ansibot ansibot removed the ci_verified label Jun 21, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

commented Jun 21, 2019

@!UNKNOWN @Akint @ApsOps @D3DeFi @K-DOT @NickatEpic @RedWhiteMiko @Sedward @abulimov @akomic @andsens @brian-brazil @bwhaley @cove @dj-wasabi @dmsimard @dstoflet @eikef @ethanculler @harrisongu @hkariti @kavu @logan2211 @martinwangjian @mcodd @n0ts @nate-kingsley @nerzhul @orgito @rubentsirunyan @seuf @skornehl @smbambling @sookido @stympy @suprememoocow @t794104 @tbielawa @tsalle @woz5999

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot ansibot removed the needs_revision label Jun 21, 2019

@Hatsikki

This comment has been minimized.

Copy link

commented Jun 21, 2019

shipit

1 similar comment
@t794104

This comment has been minimized.

Copy link
Contributor

commented Jun 21, 2019

shipit

@knaapjvd

This comment has been minimized.

Copy link
Author

commented Jul 1, 2019

Is there a way to progress this request?

@ansibot ansibot added the stale_ci label Jul 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.