我正在尝试创建带有一些示例内容的多个文件。 以下是我的剧本文件。 ---#创建一个文件并复制 -主机:远程 成为:是的 remote_user:根
tasks:
- name: create multiple files
copy:
dest: "{{ item }}"
content: |
It is sample file
with_items:
- Test1.txt
- Test2.txt
- Test3.txt
当我执行它时,出现以下错误。尝试了多种方式,但没有运气。 如何用一些示例内容创建多个文件?
致命:[Mymachine.com]:失败! => {“ msg”:“该任务包括一个 具有未定义变量的选项。错误是:“ item”为 未定义\ n \ n错误似乎出在 '/myshare/myuser/playbooks/multifile.yml':第7行,第6列,但 可能\ n不在文件中的其他位置,具体取决于确切的语法 问题。\ n \ n出现问题的行似乎是:\ n \ n任务:\ n
-名称:创建多个文件\ n ^这里\ n“}
答案 0 :(得分:1)
使用template。参见下面的示例
tasks:
- template:
src: template.j2
dest: "{{ item }}"
loop:
- Test1.txt
- Test2.txt
- Test3.txt
。
# cat template.j2
It is sample file
答案 1 :(得分:-1)
tasks:
- name: create multiple files
copy:
dest: "{{ item }}"
content: |
It is sample file
with_items:
- Test1.txt
- Test2.txt
- Test3.txt
应该在命令副本的级别:
const Product = props => {
const {name,votes} = props.product
const plus = () => {
// Call props.onVote to increase the vote count for this product
props.onVote(1,props.index);
};
const minus = () => {
// Call props.onVote to decrease the vote count for this product
props.onVote(-1,props.index);
};
return (
<li>
<span>{name}</span> - <span>votes: {votes}</span>
<button onClick={plus}>+</button>{" "}
<button onClick={minus}>-</button>
</li>
);
};
const GroceryApp = (props) => {
var [products, setProducts] = React.useState(props.products);
const onVote = (dir, index) => {};
return (
<ul>
{products.map((product,index) => (
<Product product={product} index={index} onVote={onVote} />
))}
{/* Render an array of products, which should call onVote when + or - is clicked */}
</ul>
);
}
document.body.innerHTML = "<div id='root'></div>";
ReactDOM.render(
<GroceryApp
products={[
{ name: "Oranges", votes: 0 },
{ name: "Bananas", votes: 0 }
]}
/>, document.getElementById('root')
);
let plusButton = document.querySelector("ul > li > button");
if (plusButton) {
plusButton.click();
}
console.log(document.getElementById('root').outerHTML)