centos ansible安装配置

简介:

关于ansible就不多做简绍了,直接开始安装配置

安装环境】

1
2
3
4
[root@AnsibleServer ~] # cat /etc/centos-release 
CentOS release 6.5 (Final)
[root@AnsibleServer ~] # uname -a
Linux AnsibleServer 2.6.32-431.el6.x86_64  #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

安装操作系统依赖包

1
[root@AnsibleServer ~] #yum install -y python-setuptools python-devel gmp-devel gcc java-1.7.0-openjdk unzip svnkit

下载libyaml并安装

1
2
3
4
5
6
[root@AnsibleServer ~] #wget http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz
[root@AnsibleServer ~] #tar -zxvf yaml-0.1.5.tar.gz
[root@AnsibleServer ~] #cd yaml-0.1.5
[root@AnsibleServer yaml-0.1.5] #./configure
[root@AnsibleServer yaml-0.1.5] #make
[root@AnsibleServer yaml-0.1.5] #make install

下载python依赖包并安装

1
2
3
4
5
6
7
8
9
10
11
[root@AnsibleServer ~] #wget https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.23.tar.gz
[root@AnsibleServer ~] #tar -zxvf MarkupSafe-0.23.tar.gz
[root@AnsibleServer ~] #cd MarkupSafe-0.23
[root@AnsibleServer MarkupSafe-0.23] #python setup.py install
以下同样执行
[root@AnsibleServer ~] #https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.2.tar.gz
[root@AnsibleServer ~] #https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.13.tar.gz
[root@AnsibleServer ~] #https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz
[root@AnsibleServer ~] #https://pypi.python.org/packages/source/D/Distutils2/Distutils2-1.0a4.tar.gz
[root@AnsibleServer ~] #https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz
[root@AnsibleServer ~] #https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.8.tar.gz

下载ansible并安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
在这里我们编译安装
 
[root@AnsibleServer ~] #wget https://github.com/ansible/ansible/releases/download/v2.0.0.1-1/ansible-2.0.0.1.tar.gz
也可以选择其它版本 https: //github .com /ansible/ansible
[root@AnsibleServer ~] #tar -zxvf ansible-2.0.0.1.tar.gz
[root@AnsibleServer ~] #python setup.py install
[root@AnsibleServer ~] #mkdir -p /etc/ansible
[root@AnsibleServer ~] #cp -rp examples/*  /etc/ansible/
执行以下3个命令,若都能执行,说明ansible安装成功!
ansible
ansible-playbook
ansible-doc
 
注意:从1.8版本开始,需要另外下载模块(注意模块版本与ansible版本必须匹配,否则执行可能出现莫名其妙的问
(建议先参照下github上的版本后再选择下载地址)
我们先检查下是否已经有相应的模块,如果没有要自行添加
[root@AnsibleServer modules] # cd /usr/lib/python2.6/site-packages/ansible-2.0.0.1-py2.6.egg/ansible/modules
[root@AnsibleServer modules] # ls
core  extras  __init__.py  __init__.pyc
其中core extras 就是已经添加了的模块,如果没有按以下方法添加
[root@AnsibleServer modules] #git clone https://github.com/ansible/ansible-modules-core/tree/stable-2.0.0.1 core
[root@AnsibleServer modules] #git clone https://github.com/ansible/ansible-modules-extras/tree/stable-2.0.0.1 extras

接下来我们配置AnsibleServer连通Nod1



配置SSH秘钥信任,当然ansibles也可以用密码登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
添加 /etc/hosts 主机名和地址
[root@AnsibleServer ~] # vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 
192.168.81.129 NOD1
 
生成SSH秘钥
[root@AnsibleServer ~] # ssh-keygen -t rsa
[root@AnsibleServer ~] # ssh-copy-id -i ~/.ssh/id_rsa root@nod1
验证
[root@AnsibleServer ~] #  ssh nod1
Last login: Fri Mar 25 18:07:17 2016 from 192.168.81.128
[root@NOD1 ~] # exit

配置ansible

1
2
3
4
5
6
7
8
9
[root@AnsibleServer ~] # vi /etc/ansible/hosts
[ test ]
NOD1
 
[root@AnsibleServer ansible] # ansible test -m ping
NOD1 | SUCCESS => {
     "changed" false
     "ping" "pong"
}

问题记录:

[root@AnsibleServer ~]# ansible test -m ping

/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.

  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)

NOD1 | SUCCESS => {

    "changed": false, 

    "ping": "pong"

}


意思是说系统自带 gmp 库版本太低,需要升级到 gmp 5.x

按以下方法处理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1、去 http: //ftp .gnu.org /gnu/gmp/  下载最新版并解压
 
#cd /tmp
#wget http://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2
#tar xjvf gmp-5.1.3.tar.bz2
#cd gmp-5.1.3
#./configure
#make
#make install
4、加入 ldconfig
#echo "/usr/local/lib" >> /etc/ld.so.conf.d/gmp.conf
#ldconfig
5、确认是否已经加入
 
#strings /etc/ld.so.cache|grep gmp
libgmpxx.so.4
/usr/lib64/libgmpxx .so.4
libgmp.so.10
/usr/local/lib/libgmp .so.10
libgmp.so.3
/usr/lib64/libgmp .so.3
libgmp.so
/usr/local/lib/libgmp .so
6、重新安装 pycrypto
我们要先安装pip
#wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
#tar zvxf 1.5.5.tar.gz    #解压文件
#cd pip-1.5.5/
#python setup.py install
 
然后用pip再次安装pycrypto
 
#pip uninstall pycrypto
#pip install pycrypto
 
完成后警告解除。
# ansible test -m ping
NOD1 | SUCCESS => {
     "changed" false
     "ping" "pong"
}

以上就是centos ansible安装配置,下节我们配置ansible-playbook



本文转自 jackjiaxiong 51CTO博客,原文链接:http://blog.51cto.com/xiangcun168/1755125

相关文章
|
3月前
|
应用服务中间件 Linux 网络安全
centos7 下离线安装gcc g++ nginx,并配置nginx进行网络流转发
centos7 下离线安装gcc g++ nginx,并配置nginx进行网络流转发
113 0
|
1月前
|
Java Linux
Flume【环境搭建 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证
【2月更文挑战第16天】Flume【环境搭建 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证
34 0
|
1月前
|
分布式计算 关系型数据库 MySQL
Sqoop【部署 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
【2月更文挑战第8天】Sqoop CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
100 1
|
2天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置PXE服务
PXE是Intel开发的预启动执行环境,允许工作站通过网络从远程服务器启动操作系统。它依赖DHCP分配IP,DNS服务分配主机名,TFTP提供引导程序,HTTP/FTP/NFS提供安装源。要部署PXE服务器,需关闭selinux和防火墙,安装dhcpd、httpd、tftp、xinetd及相关服务,配置引导文件和Centos7安装源。最后,通过syslinux安装引导文件,并创建pxelinux.cfg/default配置文件来定义启动参数。
9 0
|
2天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置postfix服务
安装CentOS7的Postfix和Dovecot,配置Postfix的`main.cf`文件,包括修改完全域名、允许所有IP、启用邮箱等。然后,配置Dovecot的多个配置文件以启用auth服务和调整相关设置。重启Postfix和Dovecot,设置开机自启,并关闭防火墙进行测试。最后,创建邮箱账户并在Windows邮箱客户端中添加账户设置。
9 0
|
2天前
|
运维 Linux 网络安全
【运维系列】Centos7安装配置ntp服务
配置yum并安装ntp,编辑ntp配置文件,取消17行注释,适应本机网段,22行设置使用本地时间。关闭防火墙,重启ntp服务。测试时先关闭防火墙,然后使用ntpdate命令成功同步时间。
9 0
|
2天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
9 0
|
16天前
|
网络协议
centos8 网卡 Nmcli(是network的简写 Nmcli)配置网络
centos8 网卡 Nmcli(是network的简写 Nmcli)配置网络
15 0
|
1月前
|
运维 Linux 应用服务中间件
Centos7如何配置firewalld防火墙规则
Centos7如何配置firewalld防火墙规则
49 0
|
1月前
|
存储 监控 Linux
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
【2月更文挑战第17天】Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
29 1
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)