浏览代码

Fix env in multi tasks

Bertrand Chenal 7 年之前
父节点
当前提交
ebfbff9ab7
共有 1 个文件被更改,包括 4 次插入5 次删除
  1. 4 5
      baker.py

+ 4 - 5
baker.py

@@ -586,9 +586,9 @@ def run_batch(task, hosts, cli, env=None):
     '''
     '''
     Run one task on a list of hosts
     Run one task on a list of hosts
     '''
     '''
-    env = Env(task.get('env'), env)
     out = None
     out = None
     export_env = {}
     export_env = {}
+    env = Env(export_env, task.get('env'), env)
 
 
     if task.get('multi'):
     if task.get('multi'):
         for multi in task.multi:
         for multi in task.multi:
@@ -599,12 +599,11 @@ def run_batch(task, hosts, cli, env=None):
             if network:
             if network:
                 spellcheck(cli.cfg.networks, network)
                 spellcheck(cli.cfg.networks, network)
                 hosts = cli.cfg.networks[network].hosts
                 hosts = cli.cfg.networks[network].hosts
-            child_env = multi.get('env', {}).copy()
+            child_env = Env(multi.get('env', {}), env)
             for k, v in child_env.items():
             for k, v in child_env.items():
                 # env wrap-around!
                 # env wrap-around!
-                child_env[k] = env.fmt(child_env[k])
-            run_env = Env(export_env, child_env, env)
-            out = run_batch(sub_task, hosts, cli, run_env)
+                child_env[k] = child_env.fmt(child_env[k])
+            out = run_batch(sub_task, hosts, cli, child_env)
             out = out.decode() if isinstance(out, bytes) else out
             out = out.decode() if isinstance(out, bytes) else out
             export_env['_'] = out
             export_env['_'] = out
             if multi.export:
             if multi.export: