AWX

AWX是一个利用Ansible管理项目的软件

安装

3.5.1版本安装

yum install epel-release -y
yum install ansible -y

tar ansible-tower-setup-bundle-3.5.1-1.el7.tar.gz
cd ansible-tower-setup-bundle-3.5.1-1.el7

vi inventory # 配置密码

mkdir -p /var/lib/awx

echo "3.5.1" /var/lib/awx/.tower_version

./setup.sh

最新版本下载

通过"el7 8 9"来区分不同的系统版本"Centos|RedHat 7 8 9"

wget https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-latest.el7.tar.gz

破解

不同的版本可能破解方式不一样,下面是验证过的版本。如果安装的是其它版本,可以找一找对应版本的破解方法

3.5.1版本

安装转成后执行如下命令

echo $RANDOM > /var/lib/awx/i18n.db
ansible-tower-service restart

3.8.6-2版本

安装完成后到/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/utils目录下找到licensing.py文件,对validate函数进行修改。然后重启服务即可ansible-tower-service restart

...
    def validate(self):
        # Return license attributes with additional validation info.
        attrs = copy.deepcopy(self._attrs)

		# 设置License类型为企业版
        attrs['license_type'] = 'enterprise' 
        
        # 设置Host数量为MAX_INSTANCES,即9999999。扛不住就改成自己需要的数。
        attrs['instance_count'] = MAX_INSTANCES 

		# 设置License过期日期为”2051-05-12 00:00:00“,Unix时间戳,有需要自己改
        attrs['license_date'] = '2567433600' 
	    
	    # 授权者名称
        attrs['subscription_name'] = 'mxd' 

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

		# 注释掉这个if判断
        # 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

备份/恢复

# 归档,备份配置文件
tar -cf ansible.tar /etc/ansible
tar -cf tower.tar   /etc/tower
# 使用./setup.sh 安装的话可以用下面的命令备份、恢复
./setup.sh -b
./setup.sh -r BACKUP_FILE

使用

ansible-tower-service start
ansible-tower-service status
ansible-tower-service stop
ansible-tower-service restart

删除

ansible-tower-service stop

yum remove ansible-tower* rabbitmq-server rh-python36-*

rm /etc/profile.d/rh-postgresql10-env.sh

rm -rf /etc/ansible
rm -rf /etc/tower
rm -rf /var/lib/pgsql
rm -rf /var/lib/awx
rm -rf /var/lib/rabbitmq
rm -rf /var/opt/rh/rh-postgresql10/lib/pgsql/data

错误处理记录

fatal: [localhost]: FAILED! => {"changed": false, "msg": "file not found: /var/lib/awx/.tower_version"}
mkdir -p /var/lib/awx

echo "3.5.1" /var/lib/awx/.tower_version

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Please configure passwords in the inventory file before running setup"}
cd ansible-tower-setup-bundle-3.5.1-1.el7
vi inventory # 配置密码

fatal: [localhost]: FAILED! => {"msg": "Failed to change ownership of the temporary files Ansible needs to create despite connecting as a privileged user. Unprivileged become user would be unable to read the file."}
TASK [preflight : Preflight check - check Tower license type] 
fatal: [localhost]: FAILED! => {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: invalid user: ‘awx’\n}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}
useradd awx 
chown -R awx:awx /var/lib/awx

最后更新于