Python 无法将ansible yml文件中dict键的值获取到my after.yml文件中 abc.yml: def.yml:

Python 无法将ansible yml文件中dict键的值获取到my after.yml文件中 abc.yml: def.yml:,python,dictionary,ansible,Python,Dictionary,Ansible,我可以从def.yml中的abc.yml访问d_实验室和d_位置。 然而,当我试图访问字典ema(例如ema[apple])中任何键的值时,我得到了错误 " 任务[从ema复制文件]******************************************************************************************************************* 失败:[](item=apple)=>{“changed”:true,“cmd”:“s

我可以从def.yml中的abc.yml访问d_实验室和d_位置。 然而,当我试图访问字典ema(例如ema[apple])中任何键的值时,我得到了错误

" 任务[从ema复制文件]******************************************************************************************************************* 失败:[](item=apple)=>{“changed”:true,“cmd”:“scp-oStrictHostKeyChecking=no-i~/.ssh/abc.pemroot@10.0.0.1:/tmp//tmp/test/,“delta”:“0:00:00.089524”,“end”:“2018-05-10 09:15:24.235767”,“failed”:true,“item”:“apple”,“rc”:1,“start”:“2018-05-10 09:15:24.146243”,“stderr”:“警告:永久添加了“10.0.1”(RSA)添加到已知主机列表中。\r\nscp:/tmp:非常规文件”,“标准行”:[“警告:永久性地将“10.0.0.1”(RSA)添加到已知主机列表中],“scp:/tmp:非常规文件”],“标准行”:“,“标准行”:[]) "


请告诉我如何访问ansible playbook中的词典。

看起来实际发生的错误是:

scp: /tmp: not a regular file
这可能是因为
/tmp/
是远程服务器上的目录而不是文件


您应该能够通过将
-r
参数传递到
scp
来递归复制文件。有关详细信息,请参阅。

谢谢Nathan!我面临的主要问题是从ansible yml文件中获取dict值。{{ema[item]}}解决了这个问题
- name: Load data
  hosts: CENTRAL_host
  any_errors_fatal: yes
  tasks:
    - name: Copy files from ema
      shell: "scp -oStrictHostKeyChecking=no -i ~/.ssh/abc.pem root@{{ ema['item'] }}:/tmp/ /tmp/test/"
      with_items:
        - "{{ items }}"
scp: /tmp: not a regular file