Fix deprecations on Ansible 2.7

- with_ -> loop
- fix filters as test
- test version_compare -> version
- set min_version to 2.5
This commit is contained in:
Emilien Mantel
2019-01-22 22:08:14 +01:00
parent d168219c29
commit 682339d818
17 changed files with 63 additions and 77 deletions

View File

@@ -24,13 +24,14 @@
regexp: '{{ item.0.regexp }}'
line: '{{ item.0.line }}'
dest: '{{ item.1 }}'
with_nested:
-
loop: "{{ list_one | product(list_two) | list }}"
vars:
list_one:
- regexp: '^fastcgi_param SCRIPT_FILENAME'
line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'
- regexp: '^fastcgi_param DOCUMENT_ROOT'
line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;'
-
list_two:
- '{{ nginx_etc_dir }}/fastcgi.conf'
when: nginx_fastcgi_fix_realpath

View File

@@ -1,13 +1,5 @@
---
- name: FAIL | Check possible issues
fail:
msg: "This ansible version ({{ ansible_version.full}}) is not compatible with your needs (Debian Stretch + htpasswd). Please see https://github.com/HanXHX/ansible-nginx/issues/28"
when:
ansible_distribution_major_version | version_compare('9', 'ge') and
ansible_version.full | version_compare('2.3.2', 'lt') and
nginx_htpasswd | length > 0
- name: APT | Update cache
apt:
update_cache: yes
@@ -29,11 +21,10 @@
- name: APT | Install nginx modules
apt:
pkg: "{{ item }}"
pkg: "{{ nginx_module_packages }}"
state: present
with_items: "{{ nginx_module_packages }}"
when:
ansible_distribution_major_version | version_compare('9', 'ge') or
ansible_distribution_major_version is version('9', 'ge') or
nginx_backports
- name: APT | Install python-passlib

View File

@@ -30,7 +30,7 @@
owner: "{{ item.owner | default(nginx_user) }}"
group: "{{ item.group | default(nginx_user) }}"
mode: "{{ item.mode | default('0755') }}"
with_items: "{{ nginx_sites }}"
loop: "{{ nginx_sites }}"
when: >
item.root is not defined and
(item.template is defined and item.template not in nginx_templates_no_dir) and
@@ -43,9 +43,9 @@
template:
src: "etc/nginx/sites-available/{{ item.template if item.redirect_to is not defined else '_redirect' }}.j2"
dest: "{{ nginx_etc_dir }}/sites-available/{{ item | nginx_site_filename }}"
with_items: "{{ nginx_sites }}"
notify: ['reload nginx', 'restart nginx freebsd']
when: item.state is not defined or item.state != 'absent'
loop: "{{ nginx_sites }}"
loop_control:
label: "{{ item | nginx_site_name }}"

View File

@@ -17,7 +17,7 @@
template:
src: "etc/nginx/conf.d/_upstream.conf.j2"
dest: "{{ nginx_etc_dir }}/conf.d/upstream-{{ item.name }}.conf"
with_items: "{{ nginx_upstreams }}"
loop: "{{ nginx_upstreams }}"
when: item.state is not defined or item.state == 'present'
notify: reload nginx