Trying to do a conditional that when my inventory host name once converted to a string is greater than a number
Inventory file server1 server2 server3 - .. .. .. .. .. server205 this is the important parts of the role - name: vmotion {{ inventory_hostname }} vmware_vmotion: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }} password: "{{ vcenter_password }}" vm_name: "{{ inventory_hostname }}" destination_datastore: "TP1" when: "`(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) > 150`" delegate_to: localhost - name: vmotion {{ inventory_hostname }} vmware_vmotion: hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}@scriptpro.com" password: "{{ vcenter_password }}" vm_name: "{{ inventory_hostname }}" destination_datastore: "TP2" when: "`(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) 180`" delegate_to: localhost it fails with ": "The conditional check '`(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) is even`' failed. The error was: template error while templating string: unexpected char u'`' at 6. String: {% if `(inventory_hostname | regex_replace('.*([0-9]+).*', '\\1') | int) is even` %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/etc/ansible/roles/vmotion_app/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: vmotion {{ inventory_hostname }}\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"} any thoughts are appreciated -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8f11d72d-4078-437b-94b3-907e24e8ff29%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.