On Tue, 7 Jul 2020 12:46:07 -0700 (PDT)
sandeep athoti <sandeepathoti...@gmail.com> wrote:

> when: ansible_distribution_major_version|int == 6 or ansible_fqdn == 
> "test[0-1][0-9].example.com"

See "Testing strings"
https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings

For example

  - hosts: localhost
    vars:
      hostnames:
        - test56.example.com
        - testXY.example.com
      my_regex: '^test(\d\d)\.example\.com'
    tasks:
      - debug:
          msg: OK
        loop: "{{ hostnames }}"
        when:
          item is match(my_regex)

gives

  ok: [localhost] => (item=test56.example.com) => 
    msg: OK
  skipping: [localhost] => (item=testXY.example.com)


-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200707233537.44ad24f1%40gmail.com.

Attachment: pgp3O2xDepjUI.pgp
Description: OpenPGP digital signature

Reply via email to