vim /etc/ansible/hostspython
[webserver] #方括號設置組名 www1.example.org #定義被監控主機,這邊能夠是主機名也能夠是IP地址,主機名須要修改/etc/hosts文件 www2.example.org:2222 #冒號後定義遠程鏈接端口,默認是ssh的22端口
[webserver] www[01:50].example.org ansible_ssh_user=root ansible_ssh_pass=123456 [dbbservers] db-[a:f].example.org //支持匹配a b c ... f
(1)主機變量 [webserver] www1.magedu.com http_port=80 maxRequestsChild=808 www2.magedu.com http_port=8080 maxRequestsChild=909 (2)組變量 [servers:vars] ntp_server=ntp.example.org nfs_server=nfs.example.org (3)組嵌套 [apache] http1.example.org http2.example.org [nginx] ngx1.example.org ngx2.example.org [webservers:children] apache nginx (4)inventory變量參數 參數 說明 ansible_ssh_host 將要鏈接的遠程主機名.與你想要設定的主機的別名不一樣的話,可經過此變量設置. ansible_ssh_port ssh端口號.若是不是默認的端口號,經過此變量設置. ansible_ssh_user 默認的 ssh 用戶名 ansible_ssh_pass ssh 密碼(這種方式並不安全,咱們強烈建議使用 --ask-pass 或 SSH 密鑰) ansible_ssh_private_key_file ssh 使用的私鑰文件.適用於有多個密鑰,而你不想使用 SSH 代理的狀況. ansible_ssh_common_args 此設置附加到sftp,scp和ssh的缺省命令行 ansible_sftp_extra_args 此設置附加到默認sftp命令行。 ansible_scp_extra_args 此設置附加到默認scp命令行。 ansible_ssh_extra_args 此設置附加到默認ssh命令行。 ansible_ssh_pipelining 肯定是否使用SSH管道。 這能夠覆蓋ansible.cfg中得設置。 ansible_shell_type 目標系統的shell類型.默認狀況下,命令的執行使用 'sh' 語法,可設置爲 'csh' 或 'fish'. ansible_python_interpreter 目標主機的 python 路徑.適用於的狀況: 系統中有多個 Python, 或者命令路徑不是"/usr/bin/python",好比 *BSD, 或者 /usr/bin/python ansible_*_interpreter 這裏的"*"能夠是ruby 或perl 或其餘語言的解釋器,做用和ansible_python_interpreter 相似 ansible_shell_executable 這將設置ansible控制器將在目標機器上使用的shell,覆蓋ansible.cfg中的配置,默認爲/bin/sh。
1.大小寫敏感
2.使用縮進表示層級關係
3.縮進時不容許使用Tab鍵,只容許使用空格。
4.縮進的空格數目不重要,只要相同層級的元素左側對齊便可nginx
1.對象:鍵值對的集合,又稱爲映射(mapping)/ 哈希(hashes) / 字典(dictionary) 例如:name:Example Developer 鍵 值 2.數組:一組按次序排列的值,又稱爲序列(sequence) / 列表(list) 例如:-Apple -Orange 3.純量:單個的、不可再分的值 例如:number:12.30 sure:true