首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从两个列表的连接中设置可能的事实

从两个列表的连接中设置可能的事实
EN

Stack Overflow用户
提问于 2016-09-15 14:53:59
回答 1查看 440关注 0票数 0

我希望将两个命令的输出合并为一个新变量,可以用作另一个命令的参数:

代码语言:javascript
运行
复制
---
- hosts: '{{target}}'
  tasks:

    - name: determine storage nfs mount points
      shell: /usr/sbin/showmount -d | grep -v Directories
      register: nfs
      ignore_errors: yes

    - debug: var=nfs.stdout_lines

    - name: determine storage xrd mount points
      shell: df | grep /xrd | awk '{print $6}'
      register: xrd

    - debug: var=xrd.stdout_lines

    - name: determine all mount points
      set_fact: mounts="{{ nfs.stdout_lines }} + {{ xrd.stdout_lines }}"

    - name: run gather script
      script: gather.py {{mounts.stdout_lines|join(" ")}} > /tmp/gather.txt
      register: gather

但是,当我运行它时,结果是:

代码语言:javascript
运行
复制
PLAY [ltda-srv050] *************************************************************

TASK [setup] *******************************************************************
ok: [ltda-srv050]

TASK [determine storage nfs mount points] **************************************
fatal: [ltda-srv050]: FAILED! => {"changed": true, "cmd": "/usr/sbin/showmount -d | grep -v Directories", "delta": "0:00:00.011269", "end": "2016-09-14 23:48:14.489385", "failed": true, "rc": 1, "start": "2016-09-14 23:48:14.478116", "stderr": "clnt_create: RPC: Program not registered", "stdout": "", "stdout_lines": [], "warnings": []}
...ignoring

TASK [debug] *******************************************************************
ok: [ltda-srv050] => {
    "nfs.stdout_lines": []
}

TASK [determine storage xrd mount points] **************************************
changed: [ltda-srv050]

TASK [debug] *******************************************************************
ok: [ltda-srv050] => {
    "xrd.stdout_lines": [
        "/xrd/cache1",
        "/xrd/cache2",
        "/xrd/cache3",
        "/xrd/cache4",
        "/xrd/cache5",
        "/xrd/cache6",
        "/xrd/cache7",
        "/xrd/cache8",
        "/xrd/cache9",
        "/xrd/cache10",
        "/xrd/cache11"
    ]
}

TASK [determine all mount points] **********************************************
ok: [ltda-srv050]

TASK [run gather script] *******************************************************
fatal: [ltda-srv050]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'list object' has no attribute 'stdout_lines'\n\nThe error appears to have been in '/afs/slac.stanford.edu/u/sf/ytl/work/storage/gather_file_attributes/retrieve_file_attributes.yml': line 21, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: run gather script\n      ^ here\n"}

NO MORE HOSTS LEFT *************************************************************
 [WARNING]: Could not create retry file 'retrieve_file_attributes.retry'.         [Errno 2] No such file or directory: ''


PLAY RECAP *********************************************************************
ltda-srv050                : ok=6    changed=1    unreachable=0    failed=1

帮帮忙...?

EN

回答 1

Stack Overflow用户

发布于 2016-09-15 15:29:28

mounts已经是一个列表,所以删除它尝试调用.stdout_lines会失败-删除.stdout_lines是可行的:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39504726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档