ansible-bug

Is there a way to use a regular expression to match hosts in ansible?

拥有回忆 提交于 2020-03-03 10:46:07
问题 I am trying to match hosts using a regex pattern with ansible but it is not working as expected. My inventory is as seen below: [group1] hello1 world1 hello2 world2 [group2] hello3 And my task is: - debug: msg: "{{ item }}" with_inventory_hostnames: - ~hello* From their documentation: Using regexes in patterns You can specify a pattern as a regular expression by starting the pattern with ~: ~(web|db).*\.example\.com When I execute the task there is no output. I am a n00b with regex so could