zoukankan      html  css  js  c++  java
  • ansible自动化运维工具 图形化---tower

    一、环境声明:

    系统版本

    [root@CentOS7 ~]# cat /etc/redhat-release 
    CentOS Linux release 7.7.1908 (Core) 

    确保防火墙及SElinux均为关闭状态

    机器一定要联网,因为执行./setup的时候会联网安装很多的依赖包,安装速度和你的网速有关

    yum源为阿里yum源

    二、安装Ansible

    # 安装epel-release扩展源
    [root@CentOS7 ~]# yum -y install epel-release
    
    # 安装ansible
    [root@CentOS7 ~]# yum -y install ansible
    
    # 查看ansible版本
    [root@CentOS7 ~]# ansible --version

    三、安装Ansible Tower:

    下载tower包

    下载tower包的地址

    # 安装curl postgresql
    [root@CentOS7 ~]# yum -y install vim curl postgresql 
    [root@CentOS7 ~]# mkdir /tmp/tower && cd /tmp/tower 
    
    把包上传到/tmp/tower/下面
    
    [root@CentOS7 ~]# tar xvf ansible-tower-setup-bundle-3.7.0-4.tar.gz   # 解压 
    [root@CentOS7 ~]# cd ansible-tower-setup-bundle-3.7.0-4.tar.gz      # 进入到安装目录
    
    [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# mkdir -p /var/log/tower   # 创建日志目录,要不然安装的时候报错
    # 修改配置文件
    
    [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#password=''#password='admin'#g" inventory    #登录密码
    [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#host=''#host='127.0.0.1'#g" inventory
    [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#port=''#port='5432'#g" inventory
    [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#pg_password=''#pg_password='admin'#g" inventory
    
    [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# ./setup.sh    #脚本执行的过程非常长

    四、报错以及解决方法

    第一个报错

    有可能配置文件里面有些必填项你没有填写,请看下面

     在我的实验室环境中的CentOS 7上安装Ansible塔式计算机时,我在安装过程中发现了一些问题。下载并运行安装程序时,您会看到以下通知:

    任务[飞行前:飞行前检查-读取塔式版本] ************************************** ****************************************************** * 
    致命:[本地主机]:失败!=> {“已更改”:false,“失败”:true,“ msg”:“未找到文件:/var/lib/awx/.tower_version”}
    
    ...忽略
    
    (...)
    
    任务[预检:预检检查-必须为全新安装定义密码]
    ****************************************************** ******************************************* 
    致命:[localhost]:失败!=> {“已更改”:false,“失败”:true,“ msg”:“请在运行安装程序之前在清单文件中配置密码”}
    
     要重试,请使用:--limit @ / home / ansible / ansible-tower-setup-3.1.4 / install.retry

    修复很容易。在“清单”文件中提供密码,然后重新启动安装程序。现在,它将使用提供的密码为您配置满足所有要求的Ansible,例如Postgres,Supervisord,RabbitMQ和Nginx

    [塔]
    本地主机ansible_connection = local
    
    [数据库]
    
    [所有:vars]
    admin_password =' redhat '   #必填
    
    pg_host =''                  #必填
    pg_port =''                  #必填
    pg_database ='awx'           
    pg_username ='awx'
    pg_password =' redhat '      #必填
    
    #需要对fqdns和ip地址为真
    rabbitmq_use_long_name = false

    第二个错误

    nginx启动问题

    解决方案:

    脚本异常退出之后,你查看一下进程会发现进程是在启动的状态,你把他kill掉,手动启动一下,最后执行以下脚本

    五、访问

    等待脚本全部之后访问

    账户admin,密码,开始在配置文件配置的,不知道可以去看看

    六、无需申请试用授权文件

    1,登录之后会显示这个,你可以选择申请一下,但是不一定能申请成功,也可以选择下面的方法

    2,下面的办法不行的话,直接把这个干掉就能进来了

    mv /var/lib/awx/venv/awx/lib/python3.7/site-packages/tower_license  ~

     pip3 install uncompyle6

    uncompyle6 __init__.pyc >__init__.py
    rm -f __init__.pyc __init__.pyo
    cd /var/lib/awx/venv/awx/lib/python3.7/site-packages/tower_license
    vi __init__.py
    
    新增120行, return True
    87     def _check_cloudforms_subscription(self):
    88         return True

    以下摘取license验证部分代码

    def __init__(self, **kwargs):
            self._attrs = dict(
                company_name='',
                instance_count=0,
                license_date=0,
                license_key='UNLICENSED',
            )
            if not kwargs:
                kwargs = getattr(settings, 'LICENSE', None) or {}
            self._attrs.update(kwargs)
            self._attrs['license_date'] = int(self._attrs['license_date'])
            if not self._attrs.get('subscription_name', None):
                self._attrs['subscription_name'] = self._generate_subscription_name()
            if self._check_cloudforms_subscription():
                self._generate_cloudforms_subscription()
    
        def _generate_cloudforms_subscription(self):
            self._attrs.update(dict(company_name="Red Hat CloudForms License",
                                    instance_count=9999999,
                                    license_date=253370764800,
                                    license_key='CodyGuo',
                                    license_type='enterprise',
                                    subscription_name='Red Hat CloudForms License'))
    
    
        def _check_cloudforms_subscription(self):
            return True
            if os.path.exists('/var/lib/awx/i18n.db'):
                return True
            if os.path.isdir("/opt/rh/cfme-appliance") and os.path.isdir("/opt/rh/cfme-gemset"):
                try:
                    has_rpms = subprocess.call(["rpm", "--quiet", "-q", "cfme", "cfme-appliance", "cfme-gemset"])
                    if has_rpms == 0:
                        return True
                except OSError:
                    pass
            return False
    --------------------- 

    编译

    python3 -m py_compile __init__.py
    python3 -O -m py_compile __init__.py

    重启服务

    ansible-tower-service restart

    except OSError:
    pass
    return False

    编译
    
    ```css
    python3 -m py_compile __init__.py
    python3 -O -m py_compile __init__.py

    重启服务

    ansible-tower-service restart

     具体用法看官方文档吧,ansibe tower官方

  • 相关阅读:
    数据库遇到的2个奇葩的事情
    虚IP解决程序连只读服务器故障漂移
    SQL Server 主库DML操作慢故障处理过程
    优雅地使用pt-archiver进行数据归档(转)
    Mysql表读写、索引等操作的sql语句效率优化问题
    MySQL Performance-Schema(一) 配置篇
    MySQL Performance-Schema(三) 实践篇
    MySQL Performance-Schema(二) 理论篇
    MySQL案例-并行复制乱序提交引起的同步异常
    (转)MySQL- 5.7 sys schema笔记,mysql-schema
  • 原文地址:https://www.cnblogs.com/airoot/p/14766338.html
Copyright © 2011-2022 走看看