Use Ansible's version_compare instead of doing math on strings
I'm surprised this worked all these years actually. Since Ansible version 1.6 it has been possible to use the version_compare filter instead of doing math logic on strings. See: https://docs.ansible.com/ansible/playbooks_tests.html
This commit is contained in:
parent
2ac931731a
commit
50536af990
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
- name: Install firewalld and deps
|
- name: Install firewalld and deps
|
||||||
when: ansible_distribution_major_version == '8'
|
when: ansible_distribution_major_version | version_compare('8', '==')
|
||||||
apt: pkg={{ item }} state=latest
|
apt: pkg={{ item }} state=latest
|
||||||
with_items:
|
with_items:
|
||||||
- firewalld
|
- firewalld
|
||||||
@ -8,11 +8,11 @@
|
|||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Copy firewalld public zone file
|
- name: Copy firewalld public zone file
|
||||||
when: ansible_distribution_major_version == '8'
|
when: ansible_distribution_major_version | version_compare('8', '==')
|
||||||
template: src=public.xml.j2 dest=/etc/firewalld/zones/public.xml owner=root mode=0600
|
template: src=public.xml.j2 dest=/etc/firewalld/zones/public.xml owner=root mode=0600
|
||||||
|
|
||||||
- name: Format public.xml firewalld zone file
|
- name: Format public.xml firewalld zone file
|
||||||
when: ansible_distribution_major_version == '8'
|
when: ansible_distribution_major_version | version_compare('8', '==')
|
||||||
shell: tidy -xml -iq -m -w 0 /etc/firewalld/zones/public.xml
|
shell: tidy -xml -iq -m -w 0 /etc/firewalld/zones/public.xml
|
||||||
notify:
|
notify:
|
||||||
- restart firewalld
|
- restart firewalld
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
---
|
---
|
||||||
- name: Install iptables-persistent
|
- name: Install iptables-persistent
|
||||||
when: ansible_distribution_version == '14.04'
|
when: ansible_distribution_version | version_compare('14.04', '==')
|
||||||
apt: pkg=iptables-persistent update_cache=yes
|
apt: pkg=iptables-persistent update_cache=yes
|
||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Copy /etc/iptables/rules.v4
|
- name: Copy /etc/iptables/rules.v4
|
||||||
when: ansible_distribution_version == '14.04'
|
when: ansible_distribution_version | version_compare('14.04', '==')
|
||||||
template: src=iptables.j2 dest=/etc/iptables/rules.v4 owner=root mode=0600
|
template: src=iptables.j2 dest=/etc/iptables/rules.v4 owner=root mode=0600
|
||||||
notify:
|
notify:
|
||||||
- restart iptables-persistent
|
- restart iptables-persistent
|
||||||
|
|
||||||
- name: Copy /etc/iptables/rules.v6
|
- name: Copy /etc/iptables/rules.v6
|
||||||
when: ansible_distribution_version == '14.04'
|
when: ansible_distribution_version | version_compare('14.04', '==')
|
||||||
template: src=ip6tables.j2 dest=/etc/iptables/rules.v6 owner=root group=root mode=0600
|
template: src=ip6tables.j2 dest=/etc/iptables/rules.v6 owner=root group=root mode=0600
|
||||||
notify:
|
notify:
|
||||||
- restart iptables-persistent
|
- restart iptables-persistent
|
||||||
|
|
||||||
- name: Install firewalld and deps
|
- name: Install firewalld and deps
|
||||||
when: ansible_distribution_version >= '15.04'
|
when: ansible_distribution_version | version_compare('15.04', '>=')
|
||||||
apt: pkg={{ item }} state=latest
|
apt: pkg={{ item }} state=latest
|
||||||
with_items:
|
with_items:
|
||||||
- firewalld
|
- firewalld
|
||||||
@ -25,11 +25,11 @@
|
|||||||
tags: packages
|
tags: packages
|
||||||
|
|
||||||
- name: Copy firewalld public zone file
|
- name: Copy firewalld public zone file
|
||||||
when: ansible_distribution_version >= '15.04'
|
when: ansible_distribution_version | version_compare('15.04', '>=')
|
||||||
template: src=public.xml.j2 dest=/etc/firewalld/zones/public.xml owner=root mode=0600
|
template: src=public.xml.j2 dest=/etc/firewalld/zones/public.xml owner=root mode=0600
|
||||||
|
|
||||||
- name: Format public.xml firewalld zone file
|
- name: Format public.xml firewalld zone file
|
||||||
when: ansible_distribution_version >= '15.04'
|
when: ansible_distribution_version | version_compare('15.04', '>=')
|
||||||
shell: tidy -xml -iq -m -w 0 /etc/firewalld/zones/public.xml
|
shell: tidy -xml -iq -m -w 0 /etc/firewalld/zones/public.xml
|
||||||
notify:
|
notify:
|
||||||
- restart firewalld
|
- restart firewalld
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
- name: Add GPG key for Extras repo
|
- name: Add GPG key for Extras repo
|
||||||
apt_key: id=0xC47415DFF48C09645B78609416126D3A3E5C1192 url=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC47415DFF48C09645B78609416126D3A3E5C1192 state=present
|
apt_key: id=0xC47415DFF48C09645B78609416126D3A3E5C1192 url=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC47415DFF48C09645B78609416126D3A3E5C1192 state=present
|
||||||
when: ansible_distribution_version == '14.04'
|
when: ansible_distribution_version | version_compare('14.04', '==')
|
||||||
|
|
||||||
- name: Upgrade base OS
|
- name: Upgrade base OS
|
||||||
apt: upgrade=dist update_cache=yes
|
apt: upgrade=dist update_cache=yes
|
||||||
|
@ -15,7 +15,7 @@ deb http://{{ apt_mirror }}/ubuntu/ {{ ansible_distribution_release }}-updates m
|
|||||||
###### Ubuntu Partner Repo
|
###### Ubuntu Partner Repo
|
||||||
deb http://archive.canonical.com/ubuntu {{ ansible_distribution_release }} partner
|
deb http://archive.canonical.com/ubuntu {{ ansible_distribution_release }} partner
|
||||||
|
|
||||||
{% if ansible_distribution_version == '14.04' %}
|
{% if ansible_distribution_version | version_compare('14.04', '==') %}
|
||||||
{# extras repo was discontinued after 14.10, but the latest we deploy is 14.04 #}
|
{# extras repo was discontinued after 14.10, but the latest we deploy is 14.04 #}
|
||||||
###### Ubuntu Extras Repo
|
###### Ubuntu Extras Repo
|
||||||
deb http://extras.ubuntu.com/ubuntu {{ ansible_distribution_release }} main
|
deb http://extras.ubuntu.com/ubuntu {{ ansible_distribution_release }} main
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
# dependencies certbot checks for on its first run
|
# dependencies certbot checks for on its first run
|
||||||
# taken from running certbot right after a clean Ubuntu 16.04 install
|
# taken from running certbot right after a clean Ubuntu 16.04 install
|
||||||
- name: Install certbot dependencies (Ubuntu 16.04)
|
- name: Install certbot dependencies (Ubuntu 16.04)
|
||||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04'
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('16.04', '==')
|
||||||
apt: name={{ item }} state=present update_cache=yes
|
apt: name={{ item }} state=present update_cache=yes
|
||||||
with_items:
|
with_items:
|
||||||
- augeas-doc
|
- augeas-doc
|
||||||
|
@ -63,7 +63,7 @@ server {
|
|||||||
# See: https://httpoxy.org/
|
# See: https://httpoxy.org/
|
||||||
fastcgi_param HTTP_PROXY "";
|
fastcgi_param HTTP_PROXY "";
|
||||||
|
|
||||||
{% if ansible_distribution_version == '16.04' %}
|
{% if ansible_distribution_version | version_compare('16.04', '==') %}
|
||||||
fastcgi_pass unix:/run/php/php7.0-fpm-{{ domain_name }}.sock;
|
fastcgi_pass unix:/run/php/php7.0-fpm-{{ domain_name }}.sock;
|
||||||
{% else %}
|
{% else %}
|
||||||
fastcgi_pass unix:/var/run/php5-fpm-{{ domain_name }}.sock;
|
fastcgi_pass unix:/var/run/php5-fpm-{{ domain_name }}.sock;
|
||||||
|
Loading…
Reference in New Issue
Block a user