Ansible-安装

1、软件安装

1.1、yum安装

# 配置仓库
curl -o /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install python3 python3-devel python3-pip -y
yum install ansible -y

1.2、源码安装

1.2.1、下载软件

curl -o Python-3.10.10.tgz  https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz

1.2.2、安装依赖包

yum install gcc gcc-c++ glibc-devel glibc zlib-devel zlib sqlite-devel readline-devel bzip2-devel libffi-devel -y

1.2.3、安装openssl-1.1.1

# 安装perl和所需要的模板块
yum install perl -y

# 解压安装
curl -o openssl-1.1.1t.tar.gz  https://www.openssl.org/source/openssl-1.1.1t.tar.gz && tar xvf openssl-1.1.1t.tar.gz && cd openssl-1.1.1t && ./config --prefix=/usr/local/openssl-1.1.1 && make && make install

# 创建软链接,方便管理
ln -s /usr/local/openssl-1.1.1 /usr/local/openssl

# 增加动态链接库
echo " /usr/local/openssl/lib" >>/etc/ld.so.conf
ldconfig -v

# 更换openssl
mv /usr/bin/openssl /usr/bin/openssl.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

1.2.4、安装python

tar xvf Python-3.10.10.tgz && cd Python-3.10.10 && ./configure --prefix=/usr/local/Python-3.10.10 --with-openssl=/usr/local/openssl && make && make install

cat >/etc/ld.so.conf.d/Python-3.10.10.conf <<'EOF'
/usr/local/Python-3.10.10/lib/
EOF
ldconfig 

ln -s /usr/local/Python-3.10.10/bin/python3 /usr/bin/python3
ln -s /usr/local/Python-3.10.10/bin/pip3 /usr/bin/pip3

cat << 'CAT_END' > /etc/profile.d/python.sh
#!/bin/bash
export PYTHON_HOME=/usr/local/Python-3.10.10/
export PATH=$PATH:$PYTHON_HOME/bin
CAT_END

1.2.5、pip安装ansible

pip3 install --upgrade pip -i https://pypi.douban.com/simple/
pip3 install ansible -i https://pypi.douban.com/simple/

2、确认是否安装成功

2.1、查询ansible版本

# 查询版本
ansible-server ~]# ansible --version
ansible [core 2.14.5]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Python-3.10.10/lib/python3.10/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/Python-3.10.10//bin/ansible
  python version = 3.10.10 (main, May 11 2023, 22:58:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (/usr/local/Python-3.10.10/bin/python3.10)
  jinja version = 3.1.2
  libyaml = True

2.2、ping本机

ansible-server ~]# ansible localhost -m ping
localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

 

posted @ 2023-05-11 15:09  小粉优化大师  阅读(72)  评论(0编辑  收藏  举报