【发布时间】:2018-04-01 15:49:58
【问题描述】:
我有以下列表,从脚本的输出生成。
['abc', 'abc-display-name']
['def', 'def-display-name']
['hij', 'hij-display-name']
我想在ansible中利用上面的输出来构造和执行下面的命令
oc create project -n abc -d abc-display-name
我尝试使用以下方法,但它不起作用。
---
- hosts: localhost
gather_facts: no
tasks:
- name: Executing the python script
script: convert_to_list.py
register: new_bu_list
- name: Framing the oc commands
shell: "oc create project -n {{item[0]}} -d {{item[1]}}"
with_lines: "{{ new_bu_list.stdout_lines }}"
不知道我在这里做错了什么。任何帮助将非常感激。
【问题讨论】:
-
@techraf 你能指出重复的问题吗?
-
我认为他指的是此页面右侧列表的“链接”部分中的问题,似乎是this one。
标签: ansible