2017-07-17 105 views
1

这个例子中,`args`部分时才会/数据库中不存在/路径/运行:什么是在ansible命令

# You can also use the 'args' form to provide the options. 
- name: This command will change the working directory to somedir/ and will only run when /path/to/database doesn't exist. 
    command: /usr/bin/make_database.sh arg1 arg2 
    args: 
    chdir: somedir/ 
    creates: /path/to/database 

,但为什么它args:下上市?

那么args:的设置是什么?

+0

我不确定这个问题是关于什么的...它是一个请求:“去GitHub上搜索提交历史记录,并告诉我在添加'args'字典而不是直接键值对后面的意图是什么? ?你确定这个问题在StackOverflow的范围之内吗? – techraf

回答

4

args是用来明确地传递命名参数,以行动支持“自由形式”的参数 - 附加字args在YAML(用于Ansible剧本语言),因为需要你不能对“根”的关键指定字符串值一本字典。

# here `command` is a string 
command: /bin/echo ok 

# here `user` is a dict 
user: 
    name: john 

而且由于command是一个字符串,可以使用args传递附加参数(如chdircreates等)。鉴于user是一个字典,所以你可以直接在那里添加参数(如nameuid等)。