telekom-mms/ansible-collection-icinga-director

Service objects added too early in ansible_icinga role

astam opened this issue · 4 comments

astam commented

When trying to add a service with the t_systems_mms.icinga_director.ansible_icinga role I get the message:

failed: [icinga-agent] (item=[{'service_object': ['Disk'], 'host': 'icinga-agent', 'imports': ['Check Disk Template', 'Icinga Agent Check']}, 'Disk']) => {"ansible_loop_var": "service", "changed": false, "msg": "bad return code while creating: 404. Error message: Unable to load parent referenced from service \"Disk\", failed to load icinga_service for host_id IS NULL AND service_set_id IS NULL AND object_name = 'Check Disk Template' AND object_type = 'template'", "service": [{"host": "icinga-agent", "imports": ["Check Disk Template", "Icinga Agent Check"], "service_object": ["Disk"]}, "Disk"]}

It tries to add the service at a moment while the Service Templates aren't added yet.
The order in the role is not correct. Service are the last to be added, now they are the first.

Config:

icinga_service_templates:
  - service_template_object:
    - 'Generic Service Template'
    check_interval: '30'
    retry_interval: '10'
    max_check_attempts: "2"
  - service_template_object:
    - 'Check Disk Template'
    check_command: "disk"
    imports:
      - 'Generic Service Template'
  - service_template_object:
    - 'Icinga Agent Check'
    use_agent: true
  - service_template_object:
    - 'Check Apt Template'
    check_command: "apt"
    imports:
      - 'Generic Service Template'
icinga_hosts:
  - host_object:
    - "{{ inventory_hostname }}"
    address: "{{ ansible_host }}"
    display_name: "{{ inventory_hostname }}"
    groups: []
    imports:
      - "Generic Host Template"
      - "Icinga Agent"
    vars: {}
icinga_services:
  - service_object:
    - 'Disk'
    host: "{{ inventory_hostname }}"
    imports:
      - 'Check Disk Template'
      - 'Icinga Agent Check'
  - service_object:
    - 'Apt'
    host: "{{ inventory_hostname }}"
    imports:
      - 'Check Apt Template'
      - 'Icinga Agent Check'
astam commented

Sure. Do I need to do that with a fork or a branch? Never created a pr before.

You need to fork the repository.
Here's a good tutorial on how to create a PR: https://www.dasblinkenlichten.com/how-to-create-a-github-pull-request-pr/

If you got questions, feel free to ask. :)

fixed by #135