From 7caaf207e10986c6b1e9b934a3e2ef88aac50dd0 Mon Sep 17 00:00:00 2001 From: Dougal Seeley Date: Wed, 7 Jul 2021 12:32:50 +0100 Subject: [PATCH] Fix 'list' incompatibility with galaxy in ansible<2.10 (#95) --- _dependencies/tasks/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_dependencies/tasks/main.yml b/_dependencies/tasks/main.yml index 75979d87..3d173c2d 100644 --- a/_dependencies/tasks/main.yml +++ b/_dependencies/tasks/main.yml @@ -38,9 +38,10 @@ that: "(ansible_version.full is version('2.9.6', '>=') and ansible_version.full is version('2.10.6', '<=')) or ('community.aws' in galaxy_collections and galaxy_collections['community.aws'].version is version('1.5.0', '>='))" fail_msg: "If Ansible > 2.9.6 then community.aws > 1.5.0 is required for valid community.aws.route53 support (by default in Ansible v4)." vars: + _galaxy_lookup: "{{ lookup('pipe', 'ansible-galaxy collection list', errors='ignore') }}" galaxy_collections: |- {% set res = {} -%} - {%- for sub in (lookup('pipe', 'ansible-galaxy collection list')).split('\n') | map('trim') | map('regex_replace', '\\s+', ' ') -%} + {%- for sub in (_galaxy_lookup | ternary(_galaxy_lookup, '') | trim).split('\n') | map('trim') | map('regex_replace', '\\s+', ' ') | select | list -%} {% set _ = res.update({sub.split(' ')[0]: {'version': sub.split(' ')[1]|default('')}}) -%} {%- endfor %} {{ res }}