]> arthur.barton.de Git - AnsibleRoles.git/commitdiff
Correctly cast variables to integers in Jinja templates
authorAlexander Barton <alex@barton.de>
Tue, 16 Oct 2018 14:01:58 +0000 (16:01 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 16 Oct 2018 14:01:58 +0000 (16:01 +0200)
This is required for the Ansible configuration to become compatible
with Python 3.

roles/check-mk-agent/tasks/main.yml
roles/os-base/handlers/main.yml

index 3e5ffc0b53195bca472e83aa14591e266d0fa464..3bfc39d66ce4e32a73e89bde19150c8cd20deba3 100644 (file)
@@ -21,7 +21,7 @@
   apt: >
     state=present
     name=check-mk-agent-logwatch
-  when: "ansible_distribution_major_version >= '7' and ansible_distribution_major_version < '9'"
+  when: "ansible_distribution_major_version|int >= 7 and ansible_distribution_major_version < '9'"
 
 - name: test for systemd unit files
   tags:
@@ -29,7 +29,7 @@
     - monitoring
     - packages
   stat: path=/etc/systemd/system/check_mk.socket
-  when: "ansible_distribution_major_version >= '8'"
+  when: "ansible_distribution_major_version|int >= 8"
   check_mode: no
   register: check_mk_socket_unit
 
@@ -44,7 +44,7 @@
     mode=0644
     owner=root
     src=check_mk.socket.j2
-  when: ansible_distribution_major_version >= '8' and check_mk_socket_unit.stat.exists == False
+  when: ansible_distribution_major_version|int >= 8 and check_mk_socket_unit.stat.exists == False
   notify:
     - reload systemd daemon
 
@@ -59,7 +59,7 @@
     mode=0644
     owner=root
     src=check_mk@.service.j2
-  when: ansible_distribution_major_version >= '8' and check_mk_socket_unit.stat.exists == False
+  when: ansible_distribution_major_version|int >= 8 and check_mk_socket_unit.stat.exists == False
   notify:
     - reload systemd daemon
 
@@ -73,7 +73,7 @@
     owner=root
     regexp="^[\s]*disable[\s]*="
     state=absent
-  when: "ansible_distribution_major_version < '8'"
+  when: "ansible_distribution_major_version|int < 8"
   notify:
     - restart "xinetd"
 
@@ -92,4 +92,4 @@
     enabled=yes
     name=check_mk.socket
     state=started
-  when: "ansible_distribution_major_version >= '8'"
+  when: "ansible_distribution_major_version|int >= 8"
index 92b2b2724a8f0eb257d9177abc6da508d5474245..6b0364dfec2e9e9bd7b58963483c8f9d5ffa4788 100644 (file)
@@ -7,4 +7,4 @@
     - systemd
   systemd: >
     daemon_reload=yes
-  when: "ansible_distribution == 'Debian' and ansible_distribution_major_version >= '8'"
+  when: "ansible_distribution == 'Debian' and ansible_distribution_major_version|int >= '8'"