签到成功

知道了

CNDBA社区CNDBA社区

TDSQL 集群(10.3.14.1.0) 安装 ansible 报 No such file or directory 解决方法

2021-07-27 21:18 108 0 原创 TDSQL
作者: Dave

TDSQL 安装ansible报错,如下:https://www.cndba.cn/dave/article/4622https://www.cndba.cn/dave/article/4622

[dave@www.cndba.cn settings]# ls
ansible  ansible.cfg  install_ansible.py  py_modules
[dave@www.cndba.cn settings]# ll
total 24
drwxr-xr-x. 4 root root    36 Mar 20  2019 ansible
-rw-r--r--. 1 root root 19332 Dec 30  2019 ansible.cfg
-rw-r--r--. 1 root root   663 Dec 30  2019 install_ansible.py
drwxr-xr-x. 2 root root   141 Jul 27 21:01 py_modules
[dave@www.cndba.cn settings]# ls
ansible  ansible.cfg  install_ansible.py  py_modules
[dave@www.cndba.cn settings]# python install_ansible.py
Traceback (most recent call last):
  File "install_ansible.py", line 11, in <module>
    os.chdir(work_dir)
OSError: [Errno 2] No such file or directory: ''

[dave@www.cndba.cn settings]# cat install_ansible.py
#! /usr/bin/env python
# coding: utf-8

from py_modules import functions
import os
import shutil
import sys

os_version = functions.get_os_version()
work_dir = os.path.dirname(sys.argv[0])
os.chdir(work_dir)

msg_info = functions.colored('Ansible is install successful!', 'green')

if os_version == 1:
    os.system('rpm -ivh --force ansible/centos6/*')
    print msg_info
elif os_version == 2:
    os.system('yum install -y openssl openssl-devel')
    os.system('rpm -ivh --force ansible/centos7/*')
    print msg_info
else:
    print 'The OS type neither centos-6 nor centos-7, the program will be exit!'

shutil.copy('ansible.cfg', '/etc/ansible/ansible.cfg')

这里代码比较简单, 因为看到扩展名是py的所以加了python, 注意报错的11行获取地址的方式:sys.argv[0]。https://www.cndba.cn/dave/article/4622https://www.cndba.cn/dave/article/4622

https://www.cndba.cn/dave/article/4622

所以我们这里直接执行,不加python。 如下:

https://www.cndba.cn/dave/article/4622
https://www.cndba.cn/dave/article/4622

[dave@www.cndba.cn settings]# pwd
/data/tdsql_full_install_ansible/settings
[dave@www.cndba.cn settings]# ls
ansible  ansible.cfg  install_ansible.py  py_modules

[dave@www.cndba.cn settings]#
[dave@www.cndba.cn settings]# ./install_ansible.py
-bash: ./install_ansible.py: Permission denied

这里提示权限不足,附加权限,安装成功:

https://www.cndba.cn/dave/article/4622
https://www.cndba.cn/dave/article/4622
https://www.cndba.cn/dave/article/4622

[dave@www.cndba.cn settings]# chmod a+x install_ansible.py

[dave@www.cndba.cn settings]# ./install_ansible.py
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Package 1:openssl-1.0.2k-19.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.2k-19.el7 will be installed
--> Processing Dependency: zlib-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.el7.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.el7.x86_64
--> Running transaction check
……


[dave@www.cndba.cn settings]# ansible --version
ansible 2.5.1
  config file = /data/tdsql_full_install_ansible/settings/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, Mar 20 2020, 17:08:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[dave@www.cndba.cn settings]#

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Dave

Dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 1902
    原创
  • 2
    翻译
  • 456
    转载
  • 131
    评论
  • 访问:3641966次
  • 积分:3137
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by ZhiXinTech · 皖ICP备19020168号·

        QQ交流群