@@ -515,32 +515,7 @@ def default_env(self):
515
515
self ._config .ansible_collections_path : ":" .join (collections_path_list ),
516
516
"ANSIBLE_LIBRARY" : ":" .join (self ._get_modules_directories ()),
517
517
"ANSIBLE_FILTER_PLUGINS" : ":" .join (
518
- [
519
- self ._get_filter_plugin_directory (),
520
- util .abs_path (
521
- os .path .join (
522
- self ._config .scenario .ephemeral_directory ,
523
- "plugins" ,
524
- "filter" ,
525
- ),
526
- ),
527
- util .abs_path (
528
- os .path .join (
529
- self ._config .project_directory ,
530
- "plugins" ,
531
- "filter" ,
532
- ),
533
- ),
534
- util .abs_path (
535
- os .path .join (
536
- os .path .expanduser ("~" ),
537
- ".ansible" ,
538
- "plugins" ,
539
- "filter" ,
540
- ),
541
- ),
542
- "/usr/share/ansible/plugins/filter" ,
543
- ],
518
+ self ._get_filter_plugins_directories (),
544
519
),
545
520
},
546
521
)
@@ -1012,5 +987,44 @@ def _get_modules_directories(self) -> list[str]:
1012
987
def _get_filter_plugin_directory (self ):
1013
988
return util .abs_path (os .path .join (self ._get_plugin_directory (), "filter" ))
1014
989
990
+ def _get_filter_plugins_directories (self ) -> list [str ]:
991
+ """Return list of ansilbe filter plugins includes directories."""
992
+ paths : list [str | None ] = []
993
+ if os .environ .get ("ANSIBLE_FILTER_PLUGINS" ):
994
+ paths = list (
995
+ map (util .abs_path , os .environ ["ANSIBLE_FILTER_PLUGINS" ].split (":" )),
996
+ )
997
+
998
+ paths .extend (
999
+ [
1000
+ self ._get_filter_plugin_directory (),
1001
+ util .abs_path (
1002
+ os .path .join (
1003
+ self ._config .scenario .ephemeral_directory ,
1004
+ "plugins" ,
1005
+ "filter" ,
1006
+ ),
1007
+ ),
1008
+ util .abs_path (
1009
+ os .path .join (
1010
+ self ._config .project_directory ,
1011
+ "plugins" ,
1012
+ "filter" ,
1013
+ ),
1014
+ ),
1015
+ util .abs_path (
1016
+ os .path .join (
1017
+ os .path .expanduser ("~" ),
1018
+ ".ansible" ,
1019
+ "plugins" ,
1020
+ "filter" ,
1021
+ ),
1022
+ ),
1023
+ "/usr/share/ansible/plugins/filter" ,
1024
+ ],
1025
+ )
1026
+
1027
+ return [path for path in paths if path is not None ]
1028
+
1015
1029
def _absolute_path_for (self , env , key ):
1016
1030
return ":" .join ([self .abs_path (p ) for p in env [key ].split (":" )])
0 commit comments