ansible批量管理服务概述
ansible批量功能 -- 并行
01. 可以实现批量系统操作配置
02. 可以实现批量软件服务部署
03. 可以实现批量文件数据分发
04. 可以实现批量系统信息收集
ansible批量管理服务意义
01. 提高工作的效率(部署综合架构)
02. 提高工作准确度
03. 减少维护的成本
04. 减少重复性工作
ansible软件安装部署 saltstack自动化批量管理软件 (复杂(安装 配置 应用)) 软件服务比较重
特点:
1. 没有配置文件(不需要配置)
2. 不需要启动服务
3. 客户端没有需要部署任务
管理服务器:
第一个历程:安装ansible软件
yum install -y ansible -- epel
ansible软件配置应用
ansible软件功能组成模块:
1)主机清单功能模块 /etc/ansible/hosts
2)剧本功能模块 ansible-playbook
3)核心或自定义模块
4)插件功能(python)
①主机清单
vim /etc/ansible/hosts
192.168.1.201
192.168.1.202
192.168.1.203
192.168.1.204
192.168.1.205
192.168.1.214
192.168.1.240
192.168.1.241
检查
root@XTTD-2020YSWIII:~# ansible all -m ping
192.168.1.201 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.202 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.205 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.204 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.203 | SUCCESS => {
"changed": false,
"ping": "pong"
}
定义主机组
vim /etc/ansible/hosts
[k8s_proxy]
192.168.1.201
192.168.1.202
[k8s_apiserver]
192.168.1.203
192.168.1.204
[k8s_node]
192.168.1.205
192.168.1.214
192.168.1.240
192.168.1.241
[root@rstx-53 scripts]# ansible k8s_apiserver -m ping
192.168.1.204 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.1.203 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
ip范围定义
[test]
192.168.1.[201:205]
内置变量配置连接信息
支持内置变量信息配置
[oldboy]
172.16.1.7 ansible_user=root ansible_password=123456 ansible_port=22
支持特殊变量信息配置 (剧本)
[oldboy]
172.16.1.7
[oldboy:vars]
ansible_user=root
ansible_password=123456
ansible_port=22
嵌入式配置方法
vim /etc/ansible/hosts
[k8s:children]
k8s_proxy
k8s_apiserver
k8s_node
[k8s_proxy]
192.168.1.201
192.168.1.202
[k8s_apiserver]
192.168.1.203
192.168.1.204
[k8s_node]
192.168.1.205
192.168.1.214
192.168.1.240
192.168.1.241
[root@rstx-53 scripts]# ansible k8s -m ping
192.168.1.202 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.1.201 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.1.205 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.1.204 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.1.203 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}