2017-07-17 104 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等)。