ansible的配置文件一点要多考虑,有些设定比如ssh端口啊用户啊线程啊都尽量在里面调节好
iventory的话/etc/ansible/hosts 里面可以使用正则匹配ansible从inventory开始就从inventory开始给你们讲起来1.hosts文件的基本构成是hosts hosts可以构成组也就是group,group可以构成大组--------------------------------------------------------------------------------[atlanta]host1host2[raleigh]host2host3[southeast:children]atlantaraleigh--------------------------------------------------------------------------------2.hosts可以有自己的变量group可以设定公用的变量--------------------------------------------------------------------------------[atlanta]host1 http_port=80 maxRequestsPerChild=808host2 http_port=303 maxRequestsPerChild=909[atlanta]host1host2[atlanta:vars]ntp_server=ntp.atlanta.example.comproxy=proxy.atlanta.example.com--------------------------------------------------------------------------------3.书写方式有两种列表和yml4.inventory支持匹配-------------------------------------------------------------------------------- [webservers] www[01:50].example.com [databases] db-[a:f].example.com--------------------------------------------------------------------------------5.默认有一个all组包含所有的hosts6.还可以以文件的形势记录我们的变量--------------------------------------------------------------------------------/etc/ansible/group_vars/raleigh # can optionally end in '.yml', '.yaml', or '.json'/etc/ansible/group_vars/webservers/etc/ansible/host_vars/foosball-----------------------------------------------------------------------------------ntp_server: acme.example.orgdatabase_server: storage.example.org--------------------------------------------------------------------------------7.常见的变量--------------------------------------------------------------------------------ansible_hostansible_portansible_useransible_ssh_pass 通常不使用明文,使用vault(老子不会啊)ansible_ssh_private_key_fileansible_ssh_executableThis setting overrides the default behavior to use the system ssh. This can override the ssh_executable setting in ansible.cfg.ansible_become
ansible_become_methodansible_become_useransible_become_passansible_shell_type--------------------------------------------------------------------------------8.ansible可以和cobbler这也得批量装机工具管理动态inventory很复杂,在云上环境用的也不多。