I am sure I missed something here, but couldn't find a hint in the
changelog. So far I used ansible 1.7 on Ubuntu 12.04.5 and recently
upgraded to ansible 2.0.1.0 on ubuntu 16.04 (beta) and it worked well. Only
one of my playbooks is causing problems.
The template in question sits in a sub directory called check_mk, and I
call it like this:
ansible-playbook check_mk/gen_check_mk_config.yml
It gathers facts from all my servers and compiles a single configuration
file to be put on some host. This works exactly like intended with my older
ansible 1.7 installation, but not with my 2.0.1.0 installation on ubuntu
16.04 (beta). There is no error message, it just won't expand the template
but rather copy the generic jinja2 template, unexpanded, to the destination.
This is the playbook:
$ cat check_mk/gen_check_mk_config.yml
---
- name: collect facts
hosts: all:!workstations
- hosts: myworkstation
gather_facts: no
user: root
tasks:
- name: assemble check_mk config
template: src=ei-auto.mk.j2 dest=/etc/nagios3/check_mk/conf.d/ei-auto.mk
mode=0644
register: check_mk_config
- name: update nagios
action: shell cmk -O
when: check_mk_config.changed
And this is the template:
$ cat check_mk/ei-auto.mk.j2
# {{ ansible_managed }}
# vim: filetype=python:
ipaddresses.update({
{% for h in hostvars.keys() %}
"{{ h }}": "{{ hostvars[h]['ansible_default_ipv4']['address'] }}",
{% endfor %}
})
all_hosts += [
{% for h in hostvars.keys() %}
{% set tags = hostvars[h]['check_mk_tags'] %}
"{{ h }}|agbs|{{ hostvars[h]['ansible_system'].lower().replace(' ', '')
}}{{ '|'+'|'.join(tags) if tags }}",
{% endfor %}
]
extra_host_conf["alias"] += [
{% for h in hostvars.keys() %}
( '{{ hostvars[h]['descr'] }}', ['{{ h }}'], ),
{% endfor %}
]
Again, thanks for any hint helping me to understand what I'm doing wrong or
what has changed between ansible 1.7 and 2.0.1.0 concerning templates.
Sebastian
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/dd1e7425-84e9-40f0-ba3d-76adbdf97b9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.