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

Ansible学习笔记3

ansible模块:

ansible是基于模块来工作的,本身没有批量部署的能力,真正具有批量部署的是ansible所运行的模块,ansible只是提供一个框架。

ansible支持的模块非常多,我们并不需要把每个模块记住,而只需要熟悉一些常见的模块,其他的模块在需要的需要用到的时候查询即可。

列出所有模块:

[root@localhost ansible]# ansible-doc -l | wc -l
3387

 

hostname模块:

hostname模块用于修改主机名。(注意,它不能修改/etc/hosts文件。)

将其中一台远程主机名修改为agent1.cluster.com

[root@localhost ansible]# ansible 192.168.17.105 -m hostname -a 'name=agent1.cluster.com'
192.168.17.105 | CHANGED => {"ansible_facts": {"ansible_domain": "cluster.com","ansible_fqdn": "ec2-3-64-163-50.eu-central-1.compute.amazonaws.com","ansible_hostname": "agent1","ansible_nodename": "agent1.cluster.com","discovered_interpreter_python": "/usr/bin/python"},"changed": true,"name": "agent1.cluster.com"
}

然后再到192.168.17.105的主机上去检查发现hostname已经改成了agent1.cluster.com。

[root@localhost ansible]# ansible 192.168.17.106 -m hostname -a 'name=agent2.cluster.com'
192.168.17.106 | CHANGED => {"ansible_facts": {"ansible_domain": "eu-central-1.compute.amazonaws.com","ansible_fqdn": "ec2-3-64-163-50.eu-central-1.compute.amazonaws.com","ansible_hostname": "agent2","ansible_nodename": "agent2.cluster.com","discovered_interpreter_python": "/usr/bin/python"},"changed": true,"name": "agent2.cluster.com"
}

 检查hostname,发现更新成功。

[root@localhost ~]# hostname
agent2.cluster.com

http://www.lryc.cn/news/147254.html

相关文章:

  • DP读书:鲲鹏处理器 架构与编程(十)鲲鹏软件生态与云服务
  • CSS_IOS适配状态栏和IOS底部安全区域
  • 中央仓库更新失败,IDEA报错repository is non-nexus repo, or does not indexed
  • 设计模式--代理模式
  • 链路聚合原理
  • el-table表尾添加合计行,自动合计,且特殊列自定义计算展示
  • uview ui 1.x ActonSheet项太多,设置滚动(亲测有效)
  • STM32 Cubemx 同名外设中断及回调
  • 储能辅助电力系统调峰的容量需求研究(matlab代码)
  • 非计算机科班如何丝滑转码?(本人就是有点不丝滑)
  • tensorrtx部署yolov5 6.0
  • 用html5写一个音乐播放器
  • postgresql类型转换函数
  • Go 自学:Array阵列
  • 大数据平台与数据仓库的五大区别
  • React 钩子汇总
  • Python爬取旅游网站数据机票酒店价格对比分析
  • OA项目之会议通知(查询是否参会反馈详情)
  • 如何维护自己的电脑的措施
  • VS2022 Community 安装步骤
  • vue3中mitt.js使用
  • Redis 内存淘汰策略详解
  • 初识Redis之分布式
  • 计算机网络-笔记-第三章-数据链路层
  • 【1】openGL glew示例代码分析绘制一个三角形
  • android:新建工程文件介绍
  • 强化历程6-网络系列(2023.8.30)
  • 下载MedShapeNet
  • 根据身高重建队列【贪心算法】
  • 基于Java+SpringBoot+Mybaties-plus+Vue+ElementUI 高校汉服租赁网站的 设计与实现