ansible&Tower无限hosts的License修改方法

第一步:到官方申请一个免费的license,支持10个hosts

第二步:安装Tower,直接运行tower的setup.sh如果遇到报错,根据具体内容找到对应的playbook解决

Tower下载地址

第三步:反编译task_engine.pyc文件位置awx/awx/main,反编译工具EasyPythonDecompiler

easypythondecompiler下载

wKiom1YXvWXT61yxAAFD9dM39rw137.jpg

反编译后的文件为task_engine.pyc_dis,文件重命名为task_engine.py

以下摘取license验证部分代码

def validation_info(self, show_key = True):
        if not self.fetch_ami() or not self.fetch_instance():
            return dict(valid_key=False, compliant=False)
        key = self.generate_key()
        if 'license_key' not in self.attributes:
            self.set_key(key)
        read_key = self.attributes.get('license_key', 'UNLICENSED')
        self.attributes['license_key'] = read_key
        if key != read_key:
            return dict(valid_key=False, compliant=False)
        if Host:
            current_instances = Host.objects.active_count()
        else:
            current_instances = 0
        available_instances = int(self.attributes['instance_count'])#修改这里
        self.attributes['current_instances'] = int(current_instances)
        self.attributes['available_instances'] = int(available_instances)
        self.attributes['free_instances'] = available_instances - current_instances
        self.attributes['valid_key'] = True
        self.attributes['license_date'] = sys.maxint
        self.attributes['time_remaining'] = sys.maxint
        self.attributes['grace_period_remaining'] = sys.maxint
        self.attributes['date_warning'] = False
        self.attributes['date_expired'] = False
        self.attributes['is_aws'] = True


修改内容

available_instances = int(self.attributes['instance_count'])
available_instances = 10000

删除task_engine.pyc task_engine.pyo 重启tower

希望对你有帮助

你可能感兴趣的:(license,ansible,Tower)