rewrite option is not created with default template
Closed this issue · 3 comments
Describe the bug
In the default scenario in molecule test is (see here) a rewrites option configured. But in the latest molecule output on main branch, you can not find this entry in the generated /etc/nginx/conf.d/default.conf (see here).
I also tested this locally and in all my tests (with molecule), I did not get it working to have a rewrite option in the config.
To reproduce
Run locally molecule test -s default
Expected behavior
Having a rewrite entry in the generated config, e.g. in server context:
server {
...
rewrite (.*).html(.*) $1$2 last;
...
}
Your environment
Test with debian-buster (docker) molecule the default scenario.
Additional context
I guess the changes in #189 are not covering all sequences. After changing this line
{% for rewrite in rewrite['rewrites'] if (rewrite['rewrites'] is sequence and rewrite['rewrites'] is not string) %}
to that:
{% for rewrite in rewrite['rewrites'] if (rewrite['rewrites'] is not mapping and rewrite['rewrites'] is not string) %}
the molecule test (I tested it only on debian-buster) was still good and output of the task [ansible-role-nginx-config : Print NGINX config] shows me the rewrite option in the config.
Created a PR to solve this issue. Also this Molecule test is added and I test it before my change (and of course it was failing). Add this to the verify.yml:
- name: Ensure default.conf contains 'rewrite (.*).html(.*) $1$2 last;'
lineinfile:
path: /etc/nginx/conf.d/default.conf
line: " rewrite (.*).html(.*) $1$2 last;"
state: present
check_mode: true
register: conf
failed_when: (conf is changed) or (conf is failed)
Looks like I missed some sequences indeed! I'll have a different PR ready shortly to address the remaining sequences I missed.