Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

Ansible/Nagios : problem with adding more than one template

Good Day, I have been struggling for a week on this one, but still no progess ;-(

The idea is to push new Hosts to Nagios using Ansible.

My playbook works very well if I want to push one or several hosts as long as they contain just one Template (e.g : "GENERIC_HOST") Sadly, when I try to input more templates (E.G : "GENERIC_HOST", "WINDOWS", "LOW" etc) Ansible will show ok, but eventually the new host WONT be added in Nagios. NO ERROR MESSAGE WHATSOEVER.

Here is the piece of my .yml code :

- name: createHost
uri:
  url: https://{{host_ip}}/eonapi/createHost?&username={{api_user}}&apiKey={{api_key}}
  method: POST
  body: "{
    "templateHostName": "{{item.templateHostName}}",
    "hostName": "{{item.hostName}}",
    "hostIp": "{{item.hostIp}}",
    "hostAlias": "{{item.hostAlias}}",
    "exportConfiguration": False
  }"
  status_code: 200
  body_format: json
  return_content: yes
  validate_certs: False
with_items:

    - {hostName: WFR003, hostIp: 127.0.0.2, hostAlias: PWFR003, templateHostName: [WINDOWS,LOW]}

Like I said, the file is valid and will be played by Ansible with no error message, but the new Host "WFR003" will not be added to Nagios for some reason.

Now, if I go back to just one Template :

- {hostName: WFR003, hostIp: 127.0.0.2, hostAlias: PWFR003, templateHostName: [WINDOWS]}

The new host will be added, as well as the WINDOWS template.

I hope this makes sense to you. Can anyone advise, please?

Many thanks in anticipation!!

Anthony


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...