您的位置:首页 >解析主机清单管理
发布于2025-04-18 阅读(0)
扫一扫,手机访问
主机清单配置(默认配置文件:/etc/ansible/hosts)
192.168.182.110
示例:
# -m:指定模块 # -a:指定参数 ansible 192.168.182.110 -m ping ansible 192.168.182.110 -m shell -a "df -h"

# 定义webservers组 [webservers] 192.168.182.110 192.168.182.112
示例:
# -m:指定模块 # -a:指定参数 ansible webservers -m ping ansible webservers -m shell -a "df -h"

[webservers] 192.168.182.130 ansible_ssh_user=root ansible_ssh_pass=123456
常用配置参数如下:

示例:
ansible 192.168.182.130 -m ping

[web] 192.168.182.130 192.168.182.110 [mysql] 192.168.182.111 # 子分组 [nfs:children] web mysql # 对分组统一定义变量 [nfs:vars] ansible_ssh_user=root ansible_ssh_pass=123456 ansible_ssh_port=22
示例:
ansible nfs -m ping # -o:一行显示 ansible nfs -m ping -o

cat>hostlist<<EOF [web] 192.168.182.130 192.168.182.110 [mysql] 192.168.182.111 # 子分组 [nfs:children] web mysql # 对分组统一定义变量 [nfs:vars] ansible_ssh_user=root ansible_ssh_pass=123456 ansible_ssh_port=22 EOF
示例:
# -i:指定主机列表文件 ansible -i hostlist nfs -m ping

售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
4
5
6
7
8
9