Not able to get the values of dict keys in ansible yml file into my after.yml file
1 2 3 4 5 6 | d_lab: 192.168.1.1 d_location: /ephemeral ema: apple: 10.0.0.1 orange: 10.0.0.2 jack: 10.0.0.3 |
YML:
1 2 3 4 5 6 7 8 | - 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 }}" |
我可以从def.yml的abc.yml访问d_实验室和d_位置。但是,当我试图访问字典ema(例如ema[apple])中任何键的值时,我会得到错误信息。
"
TASK [Copy files from ema] *******************************************************************************************************************
failed: [<>] (item=apple) => {"changed": true,"cmd":"scp -oStrictHostKeyChecking=no -i ~/.ssh/abc.pem [email protected]:/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":"Warning: Permanently added '10.0.0.1' (RSA) to the list of known hosts.scp: /tmp: not a regular file","stderr_lines": ["Warning: Permanently added '10.0.0.1' (RSA) to the list of known hosts.","scp: /tmp: not a regular file"],"stdout":"","stdout_lines": []}
"
请让我知道如何在一本易懂的剧本里查字典。
实际发生的错误是:
1 | scp: /tmp: not a regular file |
这可能是由于
通过将