Lxn-Chan!

(~ ̄▽ ̄)→))* ̄▽ ̄*)o

Ansible Tower是由RedHat开发的Ansible的图形化工具,能够以WebUI的方式实现Ansible的功能,提升管理效率。

Ansible Tower安装

截至本文发布前,Ansible Tower最新版本为3.8.6

  1. 首先到官方源下载安装包,也可以直接下载latest版本
    1
    wget https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-latest.tar.gz
  2. 解压
    1
    2
    tar -zxvf ansible-tower-setup-bundle-latest.el7.tar.gz
    cd ansible-tower-setup-bundle-3.8.6-2/
  3. 修改必要信息
    1
    nano inventory
    将配置文件中的密码填上
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [all:vars]
    admin_password='password'

    pg_host=''
    pg_port=''

    pg_database='awx'
    pg_username='awx'
    pg_password='tower'
    pg_sslmode='prefer' # set to 'verify-full' for client-side enforced SSL
  4. 执行安装
    1
    ./setup.sh
  5. 等待执行完成后访问直接机器IP,即可出现登录页面,默认用户名是之前改的配置文件中的admin_password值。

非官方授权

/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/utils/licensing.py文件是有关Ansible Tower授权相关的核心代码部分,只要修改其中的部分代码绕过相关逻辑即可达到授权的目的。感谢玩脱了的奶鱼博主提供的思路。

打开该文件,找到validate函数,在attrs = copy.deepcopy(self._attrs)type = attrs.get('license_type', 'none')之间添加如下代码:

1
2
3
4
attrs['license_type'] = 'enterprise'    # 设置License类型为企业版
attrs['instance_count'] = MAX_INSTANCES # 设置Host数量为MAX_INSTANCES,即9999999。扛不住就改成自己需要的数。
attrs['license_date'] = '2567433600' # 设置License过期日期为”2051-05-12 00:00:00“,Unix时间戳,有需要自己改
attrs['subscription_name'] = 'lxnchan' # 订阅名称

然后将下方的授权类型(未授权)判定部分注释掉:

1
2
3
#if (type == 'UNLICENSED' or False):
#attrs.update(dict(valid_key=False, compliant=False))
#return attrs

这个自定义函数全部改完之后看起来应该像这样:

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
def validate(self):
# Return license attributes with additional validation info.
attrs = copy.deepcopy(self._attrs)

attrs['license_type'] = 'enterprise'
attrs['instance_count'] = MAX_INSTANCES
attrs['license_date'] = '2567433600'
attrs['subscription_name'] = 'lxnchan'

type = attrs.get('license_type', 'none')

#if (type == 'UNLICENSED' or False):
#attrs.update(dict(valid_key=False, compliant=False))
#return attrs
attrs['valid_key'] = True

if Host:
current_instances = Host.objects.active_count()
else:
current_instances = 0
available_instances = int(attrs.get('instance_count', None) or 0)
attrs['current_instances'] = current_instances
attrs['available_instances'] = available_instances
free_instances = (available_instances - current_instances)
attrs['free_instances'] = max(0, free_instances)

license_date = int(attrs.get('license_date', 0) or 0)
current_date = int(time.time())
time_remaining = license_date - current_date
attrs['time_remaining'] = time_remaining
if attrs.setdefault('trial', False):
attrs['grace_period_remaining'] = time_remaining
else:
attrs['grace_period_remaining'] = (license_date + 2592000) - current_date
attrs['compliant'] = bool(time_remaining > 0 and free_instances >= 0)
attrs['date_warning'] = bool(time_remaining < self.SUBSCRIPTION_TIMEOUT)
attrs['date_expired'] = bool(time_remaining <= 0)
return attrs

改完之后重启Ansible Tower服务:

1
ansible-tower-service restart

然后强制刷新登录页即可看到已授权。


参考资料

相关链接

 简单说两句



联系站长 | 服务状态 | 友情链接

备案号:辽ICP备19013963号

萌ICP备 20219421 号

中国互联网违法和不良信息举报中心

架构版本号:8.1.6 | 本站已全面支持IPv6

正在载入运行数据(1/2)请稍后...
正在载入运行数据(2/2)请稍后...

Copyright 2024 LingXuanNing, All rights reserved.