常用参数配置:
ansible_ssh_host # 目标主机地址
ansible_ssh_port # 目标主机端口,默认22
ansible_ssh_user # 目标主机用户
ansible_ssh_pass # 目标主机ssh密码
ansible_sudo_pass # sudo密码
ansible_sudo_exe
ansible_connection # 与主机的连接类型,比如:local,ssh或者paramiko
ansible_ssh_private_key_file # 私钥地址
ansible_shell_type # 目标系统的shell类型
ansible_python_interpreter # python版本
- 编辑/etc/ansible/hosts
- 添加本机的public SSH key到目标机器的authorized_keys #ssh-copy-id
- 添加本机的私钥到Ansible
- 运行ansible all -m ping 测试是否添加成功