1

I am writing an Ansible role to build some Icinga 2 configurations, and the more important is the configuration of a client host in a distributed Icinga installation.

I want to declare Icinga 2 host variables in an Ansible variable which can be passed to an Ansible template to build a new Icinga 2 configuration file, for example:

object Host "client" {
  import "generic-host"
  address = "123.123.123.123"

  [...]

  vars.disks["Disks"] = {
    disk_all = true
  }

  vars.tcp["Description"] = {
    tcp_address = "foo.bar"
  }

  [...]    

}

I am declaring Icinga 2 host variables (for example vars.tcp["Description"] in the above example) in an Ansible variable (YAML) like this:

icinga2_clients:
  - client:
    - vars:
      - tcp:
        - name: "Description"
          params:
          - tcp_address: "foo.bar"

Do you any better idea on how to write a better Ansible variable file?

Mat
  • 1,783
  • 4
  • 22
  • 39

0 Answers0