Ansible Tower是由RedHat开发的Ansible的图形化工具,能够以WebUI的方式实现Ansible的功能,提升管理效率。
Ansible Tower安装
截至本文发布前,Ansible Tower最新版本为3.8.6
。
- 首先到官方源下载安装包,也可以直接下载latest版本。
1
| wget https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-latest.tar.gz
|
- 解压
1 2
| tar -zxvf ansible-tower-setup-bundle-latest.el7.tar.gz cd ansible-tower-setup-bundle-3.8.6-2/
|
- 修改必要信息将配置文件中的密码填上
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'
|
- 执行安装
- 等待执行完成后访问直接机器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' attrs['instance_count'] = MAX_INSTANCES attrs['license_date'] = '2567433600' attrs['subscription_name'] = 'lxnchan'
|
然后将下方的授权类型(未授权)判定部分注释掉:
这个自定义函数全部改完之后看起来应该像这样:
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): 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')
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
|
然后强制刷新登录页即可看到已授权。
参考资料
相关链接