Created
November 9, 2020 10:09
-
-
Save krdlab/72a94d198bbef245a49124e5a6a95ca9 to your computer and use it in GitHub Desktop.
Ansible の selectattr で正規表現を使う
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
gather_facts: false | |
vars: | |
targets: | |
- instance_id: 1 | |
instance_type: r4.large | |
- instance_id: 2 | |
instance_type: r5.large | |
tasks: | |
- name: list match | |
debug: | |
msg: "{{ targets | selectattr('instance_type', 'match', '^r5\\..+') | list }}" |
否定は selectattr
を rejectattr
に変更すれば良い.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
実行結果