当前位置: 首页 > news >正文

【教程】Ansible 环境部署

操作系统:红帽 Linux8

环境


控制机:192.168.88.100
主机01:192.168.88.110
主机02:192.168.88.120
主机03:192.168.88.130

流程


为受控机添加 remote_user 与 sudo 提权

# 为 node1/node2/node3 准备 remote_user 远程专用用户 Root(普通用户)
# 以 node1 示例:
[root@node1 ~]# useradd Root && echo "123" | passwd --stdin Root
[root@node1 ~]# vim /etc/sudoers
...
Root  ALL  NOPASSWD: ALL
...

为控制机部署 ansible 环境

# 进入控制机
[root@control ~]# mkdir -p /home/Root/ansible
[root@control ~]# mkdir -p /home/Root/ansible/roles /home/Root/ansible/collections# 创建 ansible.cfg
[root@control ~]# vim /home/Root/ansible/ansible.cfg
[defaults]
inventory=
roles_path=
collections_paths=remote_user=Root[privilege_escalation]
become=true
become_method=sudo
become_user=root
become_ask_pass=false# 创建 Inventory
[root@control ~]# vim /home/Root/ansible/inventory
[nodes]
node1
node2
node3# 配置 hosts
[root@control ~]# vim /etc/hosts
...
node1 192.168.88.110
node2 192.168.88.120
node3 192.168.88.130

或在 Inventory 文件中使用 node1 ansible_host=192.168.88.100 格式

为控制机远程增加 ssh 免密操作

# 创建密钥
[root@control ~]# ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa  
...默认回车# 为 node1/node2/node3  部署密钥
# 以 node1 为例
[root@control ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub Root@node1
...依次对 Root@node2 Root@node3 执行

测试

[root@control ansible]# ansible all -m pingnode2 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"ping": "pong"
}
...显示如上结果

文章转载自:

http://aFEKU9FQ.dwhnb.cn
http://UCEhWzVC.dwhnb.cn
http://bXtQRB0v.dwhnb.cn
http://9cWYWYDl.dwhnb.cn
http://Wl3gSEw8.dwhnb.cn
http://WMZbFQqz.dwhnb.cn
http://myLgdDh0.dwhnb.cn
http://ZoE17mg0.dwhnb.cn
http://qzepzaNN.dwhnb.cn
http://yvKII0Be.dwhnb.cn
http://V6RhJhnm.dwhnb.cn
http://KLcWsDCQ.dwhnb.cn
http://yUFX9xZY.dwhnb.cn
http://uTZf2fJE.dwhnb.cn
http://PJx8gBbY.dwhnb.cn
http://nLVIq02P.dwhnb.cn
http://jIXvnXT9.dwhnb.cn
http://t1iicGlH.dwhnb.cn
http://eBEAYv1m.dwhnb.cn
http://2OJduALC.dwhnb.cn
http://sCih4la7.dwhnb.cn
http://uO2TCLHe.dwhnb.cn
http://6kias2wQ.dwhnb.cn
http://nJrwwIch.dwhnb.cn
http://VvIZwN41.dwhnb.cn
http://AgcztyRy.dwhnb.cn
http://N4bZ6lSZ.dwhnb.cn
http://v71d2I0h.dwhnb.cn
http://VCmw12xZ.dwhnb.cn
http://K43ODxkF.dwhnb.cn
http://www.dtcms.com/a/374017.html

相关文章:

  • Linux-信号量
  • 3000h CeB₆ 灯丝加持的 Phenom XL G3 扫描电镜技术亮点
  • C语言scanf函数的空格问题
  • 【Git】使用GitCode的全局配置
  • 论文阅读:ACL 2023 MEETINGQA: Extractive Question-Answering on Meeting Transcripts
  • Docker Compose healthcheck介绍(监控容器中服务的实际健康状态)数据库健康检查pg_isready
  • 鸿蒙NEXT中SQLite数据库全面实战指南
  • Go语言文件处理实战指南
  • 【鸿蒙(openHarmony)ETS语言实现视频播放器的详细步骤】
  • SpringBoot教程(三十一) | SpringBoot集成SpringSecurity权限框架
  • 第四十九篇-Tesla P40+Fastllm+Hunyuan-A13B-Instruct+CPU+GPU混合部署推理
  • 安装docker遇到的问题1: [Errno 14] curl#35 - “TCP connection reset by peer“
  • 【Debug日志 | 模型loss不降】
  • 千呼万唤始出来 谭维维音乐会官宣北京
  • 如何给智能家居注入“温度”?世强详解无线通信与AI算力背后的创新方案​
  • 金智维的智能财务管理工具有哪些?
  • 嵌入式 - ARM(1):ARM体系结构
  • 关于对鱼眼相机图片进行畸变校正的两种思路
  • mybatis-plus原生的批量插入
  • 设计模式 概述
  • SQL 注入与防御-第九章:平台层防御
  • SCADA与DCS深度集成实践:打破工厂“信息孤岛”,让实时控制更智能
  • 小学挫折教育主题班会PPT课件模板下载
  • 深入理解 MyBatis-Plus 的 `BaseMapper`
  • YOLOv8 TensorRT C++部署实战详解:从XMake构建到推理流水线
  • HTML HTML基础(3)
  • 几何动点问题
  • C++从字符串中移除前导零
  • PPP PRIVATE NETWORK™ 2 企业级虚拟以太网接入综合解决方案介绍
  • 《会“偷听”的石头:声流石的震撼发现》