block in file with loop

17 views
Skip to first unread message

bala krishna

unread,
Apr 25, 2016, 8:11:12 AM4/25/16
to Ansible Project
Hi,

I am trying to write ansible playbook for Nagios client installation and configuration.

- name: untar Plugin Zip file to libexec directory
command: mount | grep -v "rootLV" | grep ext4 | awk '{print $3}'
register: dirlist

- name: create Nagios Host ServiceConfig file
blockinfile:
dest: /scripts/{{ ansible_hostname }}_svc.cfg
block: |
define service{
host_name {{ ansible_hostname }}
service_description {{ item }} filesystem
check_command check_nrpe!check_disk_boot
max_check_attempts 3
normal_check_interval 5
retry_check_interval 3
check_period 24x7
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
contact_groups touchpoint
notifications_enabled 1}

with_items: "{{dirlist.stdout_lines}}"

I was trying to create service configuration file using above playbook but it's been failing. Can someone guide me on this

Johannes Kastl

unread,
Apr 25, 2016, 11:32:37 AM4/25/16
to ansible...@googlegroups.com
On 25.04.16 11:24 bala krishna wrote:

> I was trying to create service configuration file using above playbook but it's been failing. Can someone guide me on this

Care to tell us the exact error? "failing" can mean lots of things.

Does "ansible-playbook --syntax-check yourplaybook.yml" bring any more
details that are helpful?

Johannes

signature.asc
Reply all
Reply to author
Forward
0 new messages