main_ip is a mine_function we use and return an IP depending of the main interface serving a service.
Bug details
Describe the bug
When hosts is not completed the state is broken with a message:
Rendering SLS 'hostsfile' failed: Jinja error: 'NoneType' object is not iterable
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/salt/utils/templates.py", line 392, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 22, in top-level template code
TypeError: 'NoneType' object is not iterable
; line 22
---
[...]
{%- set pillar_only = salt['pillar.get']('hostsfile:only', {}) %}
{%- set mine_hosts = salt['mine.get'](minions, minealias, tgt_type=minions_type) %}
{%- if mine_hosts is defined %}
{%- do hosts.update(mine_hosts) %}
{%- endif %}
{%- do hosts.update(pillar_hosts) %} <======================
I think this formula could be used to generate a /etc/hosts only using a mine query but no static host.
Steps to reproduce the bug
install formula hostsfile
create a pillar for your minion to configure hostsfile but let hostsfile:hosts empty
run state.sls hostsfile
Expected behaviour
I expect the formula to be able to:
run a mine query to populate /etc/hosts
to insert static entries to /etc/hosts
and any combination of mine query and static entries with none mandatory
Let's close this bug report. The problem seems to not come from the formula itself but our use of pillarstach which generates hosts: None instead of a non-existent pillar.
Your setup
Formula commit hash / release tag
3be120235d5bab28eb8f4f7ea5f8d6a250ba14d4 v0.8.0
Versions reports (master & minion)
2019.2.0
Pillar / config used
main_ip
is a mine_function we use and return an IP depending of the main interface serving a service.Bug details
Describe the bug
When hosts is not completed the state is broken with a message:
I think this formula could be used to generate a /etc/hosts only using a mine query but no static host.
Steps to reproduce the bug
hostsfile:hosts
emptystate.sls hostsfile
Expected behaviour
I expect the formula to be able to:
Attempts to fix the bug
Working on it, hoping to find a bugfix soon.
Additional context