gpt4 book ai didi

python - [可靠];使用多个字典

转载 作者:行者123 更新时间:2023-12-04 19:42:17 29 4
gpt4 key购买 nike

我正在尝试运行以下内容::
Press to see code

   - name: Snapshot BI nodes
hosts: [CLUSTER-BI,CLUSTER-BI-REPLACE]
vars_files:
- snapshot_vars.yml
user: root
any_errors_fatal: true
tasks:

- name: step 1
shell: "{{item.value}} &> {{snapshot_dir}}/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"

- name: step 2
shell: "{{item.value}} &> {{snapshot_dir}}/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"
步骤 1 后出现错误
如何为每个步骤设置一个新的 dic

最佳答案

这在没有 & 的情况下有效:

---
- name: test
hosts: localhost
vars:
ETL:
file1: "echo hello etl"
file2: "echo hello2 etl"
MSTR:
file3: "echo hello3 mstr"
file4: "echo hello4 mstr"
tasks:
- name: step 1
shell: "{{item.value}} > /tmp/ETL/{{item.key}}.log"
with_dict: "{{ ETL }}"

- name: step 2
shell: "{{item.value}} > /tmp/MSTR/{{item.key}}.log"
with_dict: "{{ MSTR }}"

我最终得到 4 个文件(ETL/MSTR 文件夹必须存在)
/tmp/ tree
.
├── ETL
│   ├── file1.log
│   └── file2.log
├── MSTR
│   ├── file3.log
│   └── file4.log

关于python - [可靠];使用多个字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53266618/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com