Ansible Tower 3.2.x 企业版无限hosts (二)

ansible tower

仅限于学习,非商业用途。

方法一 需要申请试用授权文件

修改license验证

cd /var/lib/awx/venv/awx/lib/python2.7/site-packages/tower_license
vi __init__.py

注释230行,新增两行
available_instances = 1000000 
attrs['license_type'] = 'enterprise'

以下摘取license验证部分代码

def validate(self):
    # Return license attributes with additional validation info.
    attrs = copy.deepcopy(self._attrs)
    key = attrs.get('license_key', 'UNLICENSED')
    if not self._check_cloudforms_subscription() and (key == 'UNLICENSED' or key != self._generate_key()):
        attrs.update(dict(valid_key=False, compliant=False))
        return attrs
    attrs['valid_key'] = True
    attrs['deployment_id'] = hashlib.sha1(key).hexdigest()

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

方法二 无需申请试用授权文件

修改license验证

cd /var/lib/awx/venv/awx/lib/python2.7/site-packages/tower_license
vi __init__.py

新增120行, return True
119     def _check_cloudforms_subscription(self):
120         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

编译

python -m py_compile __init__.py
python -O -m py_compile __init__.py

重启服务

ansible-tower-service restart

验证

打开–settings–VIEW YOUR LICENSE 查看
tower license

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值