ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ansible的介绍与hosts文件(一)

2022-05-24 18:03:52  阅读:309  来源: 互联网

标签:文件 ## 192.168 etc ansible hosts example


ansible是一个可以在远程主机上批量执行命令或者脚本的命令的工具

ansible底层是使用ssh协议实现的

ssh的端口是22

ping命令走的是网络层,走的协议是ICMP

ansible的安装

  epel源:一个国内的第三方库,里面有好多ios镜像

  阿里巴巴镜像源:https://developer.aliyun.com/mirror/

1.安装wget 
yum install wget -y
2.安装epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3.安装ansible
yum install ansible -y

安装完成ansible后,etc文件夹下生成ansible对应的文件与文件夹,分别是(文件:ansible.cfghe hosts),文件夹:roles

[root@192 ~]# ls /etc/ansible/
ansible.cfg  hosts  roles

ansible的默认文件hosts

[root@192 ~]# cat /etc/ansible/hosts 
# This is the default ansible 'hosts' file.  #则这是一个默认文件
#
# It should live in /etc/ansible/hosts   #它必须在/etc/ansible/hosts中才能被执行
#
#   - Comments begin with the '#' character  #  #是注释
#   - Blank lines are ignored       #空白行可以hulve
#   - Groups of hosts are delimited by [header] elements  #hosts的分组用中括号[]
#   - You can enter hostnames or ip addresses   #你可以输入一个主机名或者ip地址
#   - A hostname/ip can be a member of multiple groups  #主机名或者ip可以是一个分组的成员

# Ex 1: Ungrouped hosts, specify before any group headers.  #示例1:不被分组的主机,具体说明在任何分组之前,下面示例2之前的是实例

## green.example.com
## blue.example.com
## 192.168.100.1
## 192.168.100.10
192.168.8.139
192.168.8.140
192.168.8.141

# Ex 2: A collection of hosts belonging to the 'webservers' group  #示例2:ansible怎么分组:中括号里面是组名,中括号下面可以写IP地址或者域名

## [webservers]
## alpha.example.org
## beta.example.org
## 192.168.1.100
## 192.168.1.110

# If you have multiple hosts following a pattern you can specify# them like this:
#如果有多台主机遵循一种模式,则可以像下面一样比如192.168.1.[1:100],就是192.168.1.1--192.168.1.100

## www[001:006].example.com

# Ex 3: A collection of database servers in the 'dbservers' group #示例3:

## [dbservers]
## 
## db01.intranet.mydomain.net
## db02.intranet.mydomain.net
## 10.25.1.56
## 10.25.1.57

# Here's another example of host ranges, this time there are no
# leading 0s:

## db-[99:101]-node.example.com

[root@192 ~]# 

  

 

标签:文件,##,192.168,etc,ansible,hosts,example
来源: https://www.cnblogs.com/l1222514/p/16306489.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有