ansible学习01

一、Ansible是什么

Ansible是一个基于Python开发的轻量级自动化运维工具,有着其他自动化运维工具如puppet、cfengine、chef、func、fabric的优点,并且不需要单独安装客户端以及启动服务,只需要通过SSH就可以快速的对大量客户端实现批量系统配置、程序部署、批量运行命令等。

二、安装Ansible

[root@localhost yum.repos.d]# yum search ansible
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
=================================================================================== N/S matched: ansible ===================================================================================
centos-release-ansible-27.noarch : Ansible 2.7 packages from the CentOS ConfigManagement SIG repository
centos-release-ansible-28.noarch : Ansible 2.8 packages from the CentOS ConfigManagement SIG repository
centos-release-ansible-29.noarch : Ansible 2.9 packages from the CentOS ConfigManagement SIG repository
centos-release-ansible26.noarch : Ansible 2.6 packages from the CentOS ConfigManagement SIG repository

Name and summary matches only, use "search all" for everything.

[root@localhost yum.repos.d]# yum install centos-release-ansible-29.noarch

安装ansible的源:CentOS-SIG-ansible-29.repo

[root@localhost yum.repos.d]# ll
total 8
drwxr-xr-x. 2 root root 220 Jul 12 23:05 bak
-rw-r--r--. 1 root root 2523 Dec 26 2020 Centos-7.repo
-rw-r--r--. 1 root root 1192 Mar 31 2020 CentOS-SIG-ansible-29.repo

[root@localhost yum.repos.d]# yum install ansible

安装完成后,查看ansible配置文件,将注释#和空行去掉

[root@localhost yum.repos.d]# egrep -v "^$|^#" /etc/ansible/ansible.cfg
[defaults]
[inventory]
[privilege_escalation]
[paramiko_connection]
[ssh_connection]
[persistent_connection]
[accelerate]
[selinux]
[colors]
[diff]

三、Ansible版本查看

[root@localhost ~]# ansible --version
ansible 2.9.23
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 14 2020, 14:45:30) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

posted @ 2021-07-12 23:52  beawh  阅读(60)  评论(0编辑  收藏  举报