公司中实现运维自动化的架构中主要用到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. MySQL数据库:运算符

    运算符 比较运算符: > 大于 < 小于 >= 大于等于 <= 小于等于 = 等于 != 不等于 范围运算符: between...and...(包含边界值) 类似于 > ...

  2. Python监控主机是否存活,并发报警邮件

    利用python写了简单测试主机是否存活脚本,此脚本不适于线上使用,因为网络延迟.丢包现象会造成误报邮件,那么后续会更新判断三次ping不通后再发报警邮件,并启用多线程处理. #!/usr/bin/e ...

  3. Python语法速查: 12. 文件与输入输出

    返回目录 (1)文件基本操作 ● 文件常用操作 内置函数或方法 描述 open(name [,mode [,buffering]]) 内置函数.用来打开文件,返回一个文件对象(file对象).详见下述 ...

  4. Java之属性集(Properties类)

    Properties概述 java.util.Properties类 继承于 Hashtable ,来表示一个持久的属性集.它使用键值结构存储数据,每个键及其对应值都是一个字符串.该类也被许多Java ...

  5. Java之Collection接口(单列集合根接口)

    集合概述 集合到底是什么呢?集合:集合是java中提供的一种容器,可以用来存储多个数据 集合和数组既然都是容器,它们有啥区别呢? 区别1: 数组的长度是固定的. 集合的长度是可变的. 区别2:  数组 ...

  6. 第420期 Python 周刊

    文章.教程或讲座 Python 数据科学教程:分析 Stack Overflow 2019 年开发者调查表** https://www.youtube.com/watch?v=_P7X8tMplsw ...

  7. 如何编写高质量的 JS 函数(4) --函数式编程[实战篇]

    本文首发于 vivo互联网技术 微信公众号 链接:https://mp.weixin.qq.com/s/ZoXYbjuezOWgNyJKmSQmTw作者:杨昆 [编写高质量函数系列],往期精彩内容: ...

  8. Python time.time()方法

    描述 Python time time()返回当前时间的时间戳. 时间戳:时间戳是指格林威治时间1970年01月01日00时00分00秒(背景时间1970年01月01日08时00分00秒)起至现在的总 ...

  9. 关于ASP.NET配置

    字符串加密打开Vs的开发人员命令提示符 //加密web.config文件的连接字符串aspnet_regiis.exe -pef "connectionStrings" " ...

  10. mysql的repeat()函数

    用来复制字符串,如下'ab'表示要复制的字符串,2表示复制的份数 mysql> select repeat('ab',2); +----------------+ | repeat('ab',2 ...