Ansible-Tower--安装配置及破解
一、ansible-tower簡介
1)公司中實現運維自動化的架構中主要用到ansible,ansible腳本在部署服務器指令行中顯得不太直觀。Ansible-Tower(之前叫做awx)是將ansible的指令界面化,簡明直觀,簡單易用。
2)Ansibke-tower其實就是一個圖形化的任務調度,復雜服務部署,IT自動化的一個管理平臺,屬于發布配置管理系統,支持Api及界面操作,Django編寫。
3)Ansible-tower可以通過界面從github拉取最新playbook實施服務部署,提高生產效率。當然它也提供一個RESET API和命令行的CLI以供python腳本調用
官方網站:https://www.ansible.com/products/tower
中文指南:http://www.ansible.com.cn/docs/tower.html
官方安裝文檔:http://docs.ansible.com/ansible-tower/latest/html/quickinstall/index.html
官方源地址:http://releases.ansible.com/ansible-tower/setup-bundle/
二、ansible-tower安裝及配置
[root@tower ~]# cd /opt/ [root@tower opt]# wget https://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-3.6.2-1.el7.tar.gz [root@tower opt]# tar xf ansible-tower-setup-bundle-3.6.2-1.el7.tar.gz [root@tower opt]# cd ansible-tower-setup-bundle-3.6.2-1/ [root@tower ansible-tower-setup-bundle-3.6.2-1]# ls backup.yml bundle group_vars install.yml inventory licenses README.md rekey.yml restore.yml roles setup.sh [root@tower ansible-tower-setup-bundle-3.6.2-1]# vim inventory [tower] localhost ansible_connection=local [database] [all:vars] admin_password='tower' #tower登錄密碼 pg_host='' pg_port='' pg_database='awx' pg_username='awx' pg_password='tower' pg_sslmode='prefer' # set to 'verify-full' for client-side enforced SSL rabbitmq_username=tower rabbitmq_password='tower' rabbitmq_cookie=cookiemonster # Isolated Tower nodes automatically generate an RSA key for authentication; # To disable this behavior, set this value to false # isolated_key_generation=true # SSL-related variables # If set, this will install a custom CA certificate to the system trust store. # custom_ca_cert=/path/to/ca.crt # Certificate and key to install in nginx for the web UI and API # web_server_ssl_cert=/path/to/tower.cert # web_server_ssl_key=/path/to/tower.key # Use SSL for RabbitMQ inter-node communication. Because RabbitMQ never # communicates outside the cluster, a private CA and certificates will be # created, and do not need to be supplied. # rabbitmq_use_ssl=False # Server-side SSL settings for PostgreSQL (when we are installing it). # postgres_use_ssl=False # postgres_ssl_cert=/path/to/pgsql.crt # postgres_ssl_key=/path/to/pgsql.key #開始安裝 [root@tower ansible-tower-setup-bundle-3.6.2-1]# ./setup.sh
訪問https://10.0.0.203/
需要認證:
三、ansible-tower破解
[root@tower ~]# cd /var/lib/awx/venv/awx/lib/python3.6/site-packages/tower_license
[root@tower tower_license]# ll
total 8
-rw-r--r-- 1 root root 7764 Dec 14 01:39 __init__.pyc
drwxr-xr-x 2 root root 37 Jan 12 11:46 __pycache__
#安裝pip
[root@tower tower_license]# wget https://bootstrap.pypa.io/get-pip.py
[root@tower tower_license]# python get-pip.py
[root@tower tower_license]# pip -V
pip 19.3.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
[root@tower tower_license]# pip install uncompyle6
#反匯編init.pyc
[root@tower tower_license]# uncompyle6 __init__.pyc >__init__.py
[root@tower tower_license]# ll
total 20
-rw-r--r-- 1 root root 11502 Jan 12 12:04 __init__.py
-rw-r--r-- 1 root root 7764 Dec 14 01:39 __init__.pyc
drwxr-xr-x 2 root root 37 Jan 12 11:46 __pycache__
#修改__init__.py文件
def _check_cloudforms_subscription(self):
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:
has_rpms = subprocess.call(['rpm', '--quiet', '-q', 'cfme', 'cfme-appliance', 'cfme-gemset'])
if has_rpms == 0:
return True
except OSError:
pass
return False
....
#修改"license_date=253370764800L" 為 "license_date=253370764800"
def _generate_cloudforms_subscription(self):
self._attrs.update(dict(company_name='Red Hat CloudForms License', instance_count=MAX_INSTANCES,
license_date=253370764800, #修改
license_key='xxxx',
license_type='enterprise',
subscription_name='Red Hat CloudForms License'))
...
#------------------------------------------------------------------
#修改完重新編譯一下
[root@tower tower_license]# python -m py_compile __init__.py
[root@tower tower_license]# python -O -m py_compile __init__.py
[root@tower tower_license]# ll
total 36
-rw-r--r-- 1 root root 11521 Jan 12 12:08 __init__.py
-rw-r--r-- 1 root root 9181 Jan 12 12:08 __init__.pyc
-rw-r--r-- 1 root root 9181 Jan 12 12:08 __init__.pyo
drwxr-xr-x 2 root root 37 Jan 12 11:46 __pycache__
#重啟服務
[root@tower tower_license]# ansible-tower-service restart
Restarting Tower
Redirecting to /bin/systemctl stop rh-postgresql10-postgresql.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 rh-postgresql10-postgresql.service
Redirecting to /bin/systemctl start rabbitmq-server.service
Redirecting to /bin/systemctl start nginx.service
Redirecting to /bin/systemctl start supervisord.service
#訪問https://10.0.0.203/
四、運行測試項目
playbook將在github上創建,Ansible Tower拉取執行,Ansible Tower的playbook默認存在 /var/lib/awx/projects/
1)創建host登錄憑據
2)在github中添加playbook項目
3)在Ansible Tower添加拉取github項目的憑據
4)創建project
保存后Ansilble Tower會自動運行一次Update,如果要手動運行,點擊列表中的刷新按鈕。當github上yml文件被更新或者新增后需要點擊一下刷新按鈕,否則JOB執行得還是原來的yml
此時在Ansible Tower服務器的/var/lib/awx/projects/目錄下已經有git拉下來的完整文件結構
5)創建主機清單
6)創建任務模板
7)運行模板
點擊右側日志中change幾行可以看到詳細信息
五、安裝tomcat8測試
1)編寫playbook
---
- hosts: all
remote_user: root
tasks:
- name: "copy files to remote host"
copy:
src={{ item.src }}
dest={{ item.dest }}
with_items:
- src: /usr/local/src/jdk-8u162-linux-x64.rpm
dest: /usr/local/
- src: /usr/local/src/apache-tomcat-8.0.38.tar.gz
dest: /usr/local/
- name: "install jdk"
yum:
name: /usr/local/jdk-8u162-linux-x64.rpm
state: present
- name: "install tomcat8"
shell: cd /usr/local/ && tar xf apache-tomcat-8.0.38.tar.gz
- name: "rename file"
shell: mv /usr/local/apache-tomcat-8.0.38 /usr/local/tomcat8
- name: "start tomcat"
shell: 'nohup /usr/local/tomcat8/bin/startup.sh &'
2)創建inventory
3)創建project
4)創建模板
5)運行模板
6)瀏覽器測試tomcat
http://10.0.0.204:8080/
參考文檔:
https://blog.51cto.com/lzlutao/2382193
https://blog.51cto.com/lzlutao/2382194
https://www.cnblogs.com/kevingrace/p/11306540.html
https://www.annda.cn/2018/04/26/linux-centos-ansible-tower-install/
總結
以上是生活随笔為你收集整理的Ansible-Tower--安装配置及破解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 八大元素定位
- 下一篇: windows 10 超级优化提速 附