美文网首页
Ansible Ad-hoc和Inventory的使用

Ansible Ad-hoc和Inventory的使用

作者: _来者可是诸葛孔明_ | 来源:发表于2020-03-18 21:16 被阅读0次

Ad-hoc:ansible的命令行工具

结构:ansible <host-pattern> [options]

例子:
///列出目标主机目录
ansible 47.111.241.81 -m shell -a 'ls /root' --user=root
///操作目标主机以询问密码的方式登陆
ansible 47.111.241.81 -m shell -a 'ls /root' --user=root --ask-pass
参数
  • 普通可选参数
  • 连接目标主机参数
  • 权限控制相关参数

Inventory:定义主机关系的文件

默认路径:/etc/ansible/hosts
文件内容格式:ini

Inventory主机组
192.168.1.1
[组名]
192.168.1.2
192.168.1.3 
Inventory主机别名
test ansible_ssh_port=22 ansible_ssh_host=47.111.241.81 ansible_ssh_user=root
Inventory 批量主机组
[webservers]
www[01:50].example.com
[databases]
db-[a:f].example.com

相关文章

网友评论

      本文标题:Ansible Ad-hoc和Inventory的使用

      本文链接:https://www.haomeiwen.com/subject/uxthyhtx.html