当前位置:网站首页>Ansible实战系列一 _ 入门
Ansible实战系列一 _ 入门
2022-07-06 09:13:00 【hyh123a】
前言
一个需求:需要对多个主机进行操作。
好吧 坦白,其实是为了使用kubespray部署kubernetes做铺垫
环境
Ubuntu 20.04
1、安装
sudo apt install ansible
2、生成配置ssh秘钥
ssh-keygen
ssh-copy-id [email protected]
ssh-copy-id [email protected]
ssh-copy-id [email protected]
3、例子
sudo nano /etc/ansible/hosts
修改如下 定义用户名和密码 可不设置 默认用户名为root
[web]
172.16.106.20 ansible_ssh_user='ubuntu20' ansible_ssh_pass='AAbb0101'
172.16.106.21 ansible_ssh_user='ubuntu20' ansible_ssh_pass='AAbb0101'
172.16.106.22 ansible_ssh_user='ubuntu20' ansible_ssh_pass='AAbb0101'
ansible web -m command -a 'uptime'
输出如下
172.16.106.20 | CHANGED | rc=0 >>
10:11:57 up 17 days, 5:13, 3 users, load average: 0.47, 0.77, 1.21
172.16.106.22 | CHANGED | rc=0 >>
10:11:57 up 17 days, 6:08, 1 user, load average: 1.34, 1.13, 1.25
172.16.106.21 | CHANGED | rc=0 >>
10:11:57 up 17 days, 5:45, 1 user, load average: 1.44, 1.92, 1.99
其他
如有遗漏欢迎补充
如有问题欢迎留言
如有作用欢迎点赞
边栏推荐
- MySQL27-索引優化與查詢優化
- API learning of OpenGL (2005) gl_ MAX_ TEXTURE_ UNITS GL_ MAX_ TEXTURE_ IMAGE_ UNITS_ ARB
- Discriminant model: a discriminant model creation framework log linear model
- [recommended by bloggers] asp Net WebService background data API JSON (with source code)
- MySQL flush operation
- Ubuntu 20.04 安装 MySQL
- IDEA 导入导出 settings 设置文件
- Advantages and disadvantages of evaluation methods
- MySQL transaction log
- C language advanced pointer Full Version (array pointer, pointer array discrimination, function pointer)
猜你喜欢
随机推荐
MySQL21-用户与权限管理
Mysql22 logical architecture
CSDN问答标签技能树(五) —— 云原生技能树
[recommended by bloggers] asp Net WebService background data API JSON (with source code)
第一篇博客
Have you mastered the correct posture of golden three silver four job hopping?
导入 SQL 时出现 Invalid default value for ‘create_time‘ 报错解决方法
【博主推荐】SSM框架的后台管理系统(附源码)
CSDN问答标签技能树(二) —— 效果优化
Global and Chinese markets of static transfer switches (STS) 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL27-索引優化與查詢優化
Csdn-nlp: difficulty level classification of blog posts based on skill tree and weak supervised learning (I)
Install mysql5.5 and mysql8.0 under windows at the same time
MySQL21-用戶與權限管理
Emotional classification of 1.6 million comments on LSTM based on pytoch
There are three iPhone se 2022 models in the Eurasian Economic Commission database
解决扫描不到xml、yml、properties文件配置
Invalid global search in idea/pychar, etc. (win10)
Ansible实战系列二 _ Playbook入门
Navicat 導出錶生成PDM文件