公司中实现运维自动化的架构中主要用到ansible,ansible脚本在部署服务器指令行中显得不太直观。Ansible-Tower(之前叫做awx)是将ansible的指令界面化,简明直观,简单易用。Ansibke-tower其实就是一个图形化的任务调度,复杂服务部署,IT自动化的一个管理平台,属于发布配置管理系统,支持Api及界面操作,Django编写。Ansible-tower可以通过界面从github拉取最新playbook实施服务部署,提高生产效率。当然它也提供一个RESET API和命令行的CLI以供python脚本调用。下面是Ansible-Tower的搭建记录,在此分享下:

Ansible-Tower目前支持7.4+的版本,可以使用yum update -y命令更新;

1. 安装Ansible的epel源
[root@ansible ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core) [root@ansible ~]# python -V
Python 2.7.5 关闭selinux
[root@ansible ansible-tower]# vim /etc/sysconfig/selinux
.........
SELINUX=disabled
[root@ansible ansible-tower]# setenforce 0
setenforce: SELinux is disabled
[root@ansible ansible-tower]# getenforce
Disabled 关闭防火墙
[root@ansible ansible-tower]# systemctl stop firewalld
[root@ansible ansible-tower]# systemctl disable firewalld
[root@ansible ansible-tower]# firewall-cmd --state
not running ========================================================================================================
需要注意:如果开启了防火墙,需要开放对应访问策略(这里是测试环境,就关闭了防火墙)
[root@ansible ansible-tower]# firewall-cmd --permanent --zone=public --add-port=80/tcp
[root@ansible ansible-tower]# systemctl restart firewalld.service
======================================================================================================== 2. 安装Ansible
[root@ansible ~]# yum install -y ansible
[root@ansible ~]# ansible --version
ansible 2.8.2
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Jun 20 2019, 20:27:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] 3. 按照ansible-tower(官网下载地址: https://releases.ansible.com/ansible-tower/setup/)
下载地址:https://pan.baidu.com/s/1Uz-BFZXkjOr4FLg-lFF4fQ
提取密码:3e97 [root@ansible ~]# cd /usr/local/src/
[root@ansible src]# wget https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-3.2.6-1.el7.tar.gz
[root@ansible src]# tar -zvxf ansible-tower-setup-bundle-3.2.6-1.el7.tar.gz
[root@ansible src]# mv ansible-tower-setup-bundle-3.2.6-1.el7 /usr/local/ansible-tower
[root@ansible src]# cd /usr/local/ansible-tower
[root@ansible ansible-tower]# ls
backup.yml bundle group_vars install.yml inventory licenses README.md restore.yml roles setup.sh 配置inventory文件 (注意:admin_password处填写的就是ansible-tower登陆密码,密码可以自行设定)
[root@ansible ansible-tower]# sed -i "s#password=''#password='tower@123'#g" inventory
[root@ansible ansible-tower]# sed -i "s#host=''#host='127.0.0.1'#g" inventory
[root@ansible ansible-tower]# sed -i "s#port=''#port='5432'#g" inventory 安装前先创建/var/log/tower的日志目录,不然会报错
[root@ansible ansible-tower]# mkdir -p /var/log/tower 接着执行ansible-tower的安装脚本,如果网络没有问题的话耐心等待安装完成即可.
[root@ansible ansible-tower]# ./setup.sh

安装完成没报错的话即可访问web页面,这里测试机地址为172.16.60.244,则访问ansible-tower地址就是https://172.16.60.244, 默认初始页面如下:

默认用户为admin,密码为inventory文件admin_password字段配置的密码(如上设置的密码为"tower@123")。接着会提示让选择license文件,导入license,没有的话,点击REQUEST LICENSE,去官方 (https://www.ansible.com/license) 申请免费试用,填写个人信息后 (邮箱要填写正确,其他信息可随便填写) 会把license发到填写的邮箱。这里分享一个已经申请下来的license文件  (提取密码为: krwe)。提交license并登录成功后默认初始页面如下:

申请的免费版license最多只能添加10个主机, 且有时间限制。 下面记录下破解方法:

[root@k8s-node01 ansible-tower]# cd /var/lib/awx/venv/awx/lib/python2.7/site-packages/tower_license
[root@k8s-node01 tower_license]# ll
total 28
-rw-r--r-- 1 root root 10417 Aug 11 2018 __init__.py
-rw-r--r-- 1 root root 6352 Aug 11 2018 __init__.pyc
-rw-r--r-- 1 root root 6352 Aug 11 2018 __init__.pyo 修改__init__.py文件
将119行和120行修改为如下内容,特别需要注意格式.
也就是在原文119和120行之间添加了一行"return True"内容,格式对齐即可 (即加入的"return True" 跟 后面的if语句保持对齐,不然后面重新编译会报错)。
[root@k8s-node01 tower_license]# vim __init__.py
.........
119 def _check_cloudforms_subscription(self):
120 return True
121 if os.path.exists('/var/lib/awx/i18n.db'):
122 return True
123 if os.path.isdir("/opt/rh/cfme-appliance") and os.path.isdir("/opt/rh/cfme-gemset"):
124 try:
......... 修改完重新编译一下:
[root@k8s-node01 tower_license]# python -m py_compile __init__.py
[root@k8s-node01 tower_license]# python -O -m py_compile __init__.py
[root@k8s-node01 tower_license]# 重启服务:
[root@k8s-node01 tower_license]# ansible-tower-service restart
Restarting Tower
Redirecting to /bin/systemctl stop postgresql-9.6.service
Redirecting to /bin/systemctl stop rabbitmq-server.service
Redirecting to /bin/systemctl stop nginx.service
Redirecting to /bin/systemctl stop supervisord.service
Redirecting to /bin/systemctl start postgresql-9.6.service
Redirecting to /bin/systemctl start rabbitmq-server.service
Redirecting to /bin/systemctl start nginx.service
Redirecting to /bin/systemctl start supervisord.service
[root@k8s-node01 tower_license]#

重新打开ansible-tower界面的"settings"–>"VIEW YOUR LICENSE",发现"Hosts Available"变成了9999999台,说明破解成功,如下:

需要注意:发现最新版本或者高版本的ansible-tower没有__init__.py文件需要对__init__.pyc进行反编译,然后进行HOSTS限制破解操作:

比如下载ansible-tower-setup-latest.tar.gz最新的包,按照上面的按照部署,将ansible-tower部署到/usr/local目录下
[root@ansible ~]# python --version
Python 2.7.5 [root@ansible ~]# cd /var/lib/awx/venv/awx/lib/python3.6/site-packages/tower_license
[root@ansible tower_license]# ll
total 8
-rw-r--r-- 1 root root 5055 Aug 12 21:13 __init__.pyc
drwxr-xr-x 2 root root 37 Aug 22 15:19 __pycache__ 1)接下来进行反汇编init.pyc
[root@ansible tower_license]# yum install python-pip
[root@ansible tower_license]# pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7) [root@ansible tower_license]# pip install uncompyle6
[root@ansible tower_license]# uncompyle6 --version
uncompyle6 3.3.5 [root@ansible tower_license]# uncompyle6 __init__.pyc >__init__.py
[root@ansible tower_license]# ll
total 16
-rw-r--r-- 1 root root 7301 Aug 22 15:42 __init__.py
-rw-r--r-- 1 root root 5055 Aug 12 21:13 __init__.pyc
drwxr-xr-x 2 root root 37 Aug 22 15:19 __pycache__ 2)修改__init__.py文件
[root@ansible tower_license]# vim __init__.py
........
# _check_cloudforms_subscription方法修改如下内容,特别需要注意格式。
def _check_cloudforms_subscription(self):
# 只需要添加下面一行直接返回 True即可。注意格式要跟if对对齐。
return True
if os.path.exists('/var/lib/awx/i18n.db'):
return True
else:
if os.path.isdir('/opt/rh/cfme-appliance'):
if os.path.isdir('/opt/rh/cfme-gemset'):
pass
try:
........ #修改"license_date=253370764800L" 为 "license_date=253370764800"
........ def _generate_cloudforms_subscription(self):
self._attrs.update(dict(company_name='Red Hat CloudForms License', instance_count=9999999,
license_date=253370764800, # 只需要修改这一行
license_key='xxxx',
license_type='enterprise',
subscription_name='Red Hat CloudForms License'))
........ 3)修改完重新编译一下
[root@ansible tower_license]# python -m py_compile __init__.py
[root@ansible tower_license]# python -O -m py_compile __init__.py
[root@ansible tower_license]# 4)重启服务
[root@ansible tower_license]# ansible-tower-service restart 5)最后打开url (https://your_ip/#/license) ,发现"Hosts Available"变成了"9999999"台, 到期时间变成了"01/01/9999", 说明破解成功了。

Ansible-Tower自动化运维管理环境 - 安装破解记录的更多相关文章

  1. Ansible 自动化运维管理工具

    Ansible 自动化运维管理工具 1.Ansible概述 2.Ansible部署 3.Ansible模块 1.Ansible概述: Ansible是一个基于Python开发的配置管理和应用部署工具, ...

  2. Linux运维之Ansible自动化运维管理工具

    Ansible简介:Ansible是一个简单高效的自动化运维管理工具,用Python开发,能大批量管理N多台机器,可以并发的在多台机器上部署应用.安装软件.执行命令.配置和编排任务.后面会提到批量安装 ...

  3. ansible自动化运维管理工具

    1.Ansible介绍 1)Ansible:Ansible的核心程序 2)Host Inventory:(默认路径:/etc/ansible/hosts)记录了每一个由Ansible管理的主机信息,信 ...

  4. opsmanage 自动化运维管理平台

    关闭防火墙.selinux 更换阿里云 yum源 依赖环境 yum install -y epel-releaseyum install vim net-tools nmon htop rsync t ...

  5. django 实现linux运维管理平台

    概述 使用django实现一个linux运维管理平台,可以实现注册登录,机器管理 ,服务器批量操作,服务器性能监控. 详细 代码下载:http://www.demodashi.com/demo/112 ...

  6. 国产安全自主可控IT智能运维管理解决方案

    新一轮科技革命和产业变革席卷全球,大数据.云计算.物联网.人工智能.区块链等新技术不断涌现,数字经济正深刻地改变着人类的生产和生活方式,作为经济增长新动能的作用日益凸显.伴随增长的,还有网络中不断涌现 ...

  7. CentOS 7运维管理笔记(9)----Apache 安全控制与认证

    Apache 提供了多种安全控制手段,包括设置Web访问控制.用户登陆密码认证及 .htaccess 文件等.通过这些技术手段,可以进一步提升Apache服务器的安全级别,减少服务器受攻击或数据被窃取 ...

  8. Python+Django+ansible playbook自动化运维项目实战☝☝☝

    Python+Django+ansible playbook自动化运维项目实战☝☝☝  一.入门引导 DevOPSDevOps(英文Development和Operations的组合)是一组过程.方法 ...

  9. 华为云和开源Istio运维管理对比样例应用部署

    前言 在公有云方面,华为云已经率先将 Istio 作为产品投入到公有云中进行商业应用中,保持和开源istio高度兼容,做了商业化的运维管理界面,同时进行了性能优化.这里我们做一次验证测试. Booki ...

随机推荐

  1. [转载]——Automatic Tuning of Undo_retention Causes Space Problems (文档 ID 420525.1)

    Automatic Tuning of Undo_retention Causes Space Problems (文档 ID 420525.1) 转到底部 In this Document   Sy ...

  2. 三feng云,免费虚拟主机和免费云服务器

    三feng云,免费虚拟主机和免费云服务器 链接:https://www.sanfengyun.com 虚拟主机 虚拟服务器 BGP多线路 独立IP地址 送免备案系统,永久免费 具备高在线率.高安全性. ...

  3. asp开发类型判段

    Asp的东西有许多,asp的类型便是其中之一,如同Asp的数据类型只需一个那便是"variant ". 它是一种特别的数据类型可以依据它的运用标明许多不同品种的信息(cnhfjj) ...

  4. Ubuntu16.04VIM无法补全错误记录

    先记录一下YouCompleteMe的安装过程. 按照教程进行安装 1. 安装 vundle # vundle是vim的包管理器,十分好用 cv@cv: ~$ git clone https://gi ...

  5. Python函数(函数定义、函数调用)用法详解

    Python 中,函数的应用非常广泛,前面章节中我们已经接触过多个函数,比如 input() .print().range().len() 函数等等,这些都是 Python 的内置函数,可以直接使用. ...

  6. idea实战技巧

    一.背景 为什么想写这个,因为编码一线更多的是实战,实战中,可能一个快捷键,一个小技巧,就能省很多时间. 本文会持续记录,持续更新. 二.技巧 1.全局替换(带正则) 场景是: 多profile的情况 ...

  7. Excel导入导出DataGridView

    /// <summary> /// excel表保存到dataTable中 /// </summary> /// <param name="path" ...

  8. 架构视角 - DDD、TDD、MDD领域驱动、测试驱动还是模型驱动?

    提出问题 「领域驱动设计」之于微服务,好比麦当劳之于汉堡(个人更喜欢肯德基,汉堡要大些,麦当劳的汉堡,想吃顿饱饭,请先给我上6个

  9. js-事件函数调用简化

    // 一般写法 function fn(event) { console.log(event) } div.onclick = function (event) { fn(event) } ===== ...

  10. 下载EPM包详细运行日志

    事务码:UJFS,选择包运行的环境名称. 从root根目录下进入对应环境->模型目录,找到privatepublications 文件夹对应的账号文件夹(运行包的账号名称) 进入tempfile ...