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

Linux学习-Ansible(一)

环境- Rocky-Linux8.6

安装部署Ansible

# 安装ansible
[root@harbor ansible]# dnf install -y ansible-core
#查看安装信息
[root@harbor ansible]# ansible-doc --version
ansible-doc [core 2.12.2]config file = /root/ansible/ansible.cfgconfigured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']ansible python module location = /usr/lib/python3.8/site-packages/ansibleansible collection location = /root/.ansible/collections:/usr/share/ansible/collectionsexecutable location = /usr/bin/ansible-docpython version = 3.8.12 (default, May 10 2022, 23:46:40) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]jinja version = 2.10.3libyaml = True: << EOF
Ansible认证方式有密码认证和公私钥认证两种方式
EOF
# 为“ssh”生成、管理和转换认证密钥,它支持RSA和DSA两种认证密钥,默认RSA
[root@harbor ansible]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)?
#ssh-copy-id可以把本地主机的公钥复制到远程主机的authorized_keys文件上
[root@harbor ansible]# ssh-copy-id -i /root/.ssh/id_rsa 192.168.29.161
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.29.161 (192.168.29.161)' can't be established.
ECDSA key fingerprint is SHA256:77a8CWnJMqyZH4QnCrcwH81FefxPv38r7+pw5yO0OJI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.29.161's password:Number of key(s) added: 1Now try logging into the machine, with:   "ssh '192.168.29.161'"
and check to make sure that only the key(s) you wanted were added.[root@harbor ansible]# pwd
/root/ansible
#配置Ansible配置文件和主机列表
[root@harbor ansible]# ls
ansible.cfg  hostlist
[root@harbor ansible]# cat ansible.cfg hostlist
[defaults]
inventory         = hostlist        #主机清单列表文件
host_key_checking = False           #Ansible连接客户端时的SSH主机密钥检查,避免第一次连接到新主机时出现连接确认,即首交连接是否需要key认证
#主机清单文件中可以是IP地址或主机名
[web]
192.168.29.161
192.168.29.162
# 查看web组下的主机列表
[root@harbor ansible]# ansible web --listhosts (2):192.168.29.161192.168.29.162
# 向web主机组下主机发送ping命令
[root@harbor ansible]# ansible web -m ping
192.168.29.161 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"ping": "pong"
}
192.168.29.162 | SUCCESS => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"},"changed": false,"ping": "pong"
}

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 自建,前端sdk库(react-utils-dev-sdk)
  • C++入门项目:Linux下C++轻量级Web服务器 跑通|运行|测试(小白进)
  • android kotlin基础复习 enum
  • 【C++】_list常用方法解析及模拟实现
  • 高级java每日一道面试题-2024年9月05日-数据库篇-谈一下聚集索引和非聚集索引?
  • SQL server 删除重复行
  • 〖open-mmlab: MMDetection〗解析文件:mmdet/models/detectors/two_stage.py
  • 1.9 Crash(三,Ramdump的分析)
  • 如何解决 Windows PowerShell 中 “无法加载文件 pnpm.ps1” 的错误
  • PTR_ERR 系列函数和宏
  • CCF-CSP认证考试准备第十三天:201909-3 字符画(大模拟)
  • 数据结构————单链表
  • Unity3D ARPG(动作角色扮演游戏)设计与实现详解
  • Python 基础之模块与文件操作(Basic Modules and File Operations in Python)
  • HTML、CSS实现树状图
  • python3.6+scrapy+mysql 爬虫实战
  • create-react-app做的留言板
  • git 常用命令
  • gulp 教程
  • java取消线程实例
  • js递归,无限分级树形折叠菜单
  • Mysql数据库的条件查询语句
  • node学习系列之简单文件上传
  • Python_网络编程
  • seaborn 安装成功 + ImportError: DLL load failed: 找不到指定的模块 问题解决
  • 分布式任务队列Celery
  • 浮动相关
  • 前端面试之闭包
  • - 语言经验 - 《c++的高性能内存管理库tcmalloc和jemalloc》
  • 走向全栈之MongoDB的使用
  • Nginx实现动静分离
  • SAP CRM里Lead通过工作流自动创建Opportunity的原理讲解 ...
  • 国内唯一,阿里云入选全球区块链云服务报告,领先AWS、Google ...
  • ​什么是bug?bug的源头在哪里?
  • # Panda3d 碰撞检测系统介绍
  • #Linux(Source Insight安装及工程建立)
  • $.type 怎么精确判断对象类型的 --(源码学习2)
  • (11)MATLAB PCA+SVM 人脸识别
  • (26)4.7 字符函数和字符串函数
  • (33)STM32——485实验笔记
  • (C)一些题4
  • (二)pulsar安装在独立的docker中,python测试
  • (附源码)计算机毕业设计SSM疫情社区管理系统
  • (黑马出品_高级篇_01)SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式
  • (简单有案例)前端实现主题切换、动态换肤的两种简单方式
  • (一)项目实践-利用Appdesigner制作目标跟踪仿真软件
  • (转)Groupon前传:从10个月的失败作品修改,1个月找到成功
  • (转)为C# Windows服务添加安装程序
  • (转载)Linux 多线程条件变量同步
  • ***linux下安装xampp,XAMPP目录结构(阿里云安装xampp)
  • .bat批处理(一):@echo off
  • .NET HttpWebRequest、WebClient、HttpClient
  • .Net MVC + EF搭建学生管理系统
  • .NET 服务 ServiceController
  • .NET 设计模式—简单工厂(Simple Factory Pattern)