一、環境聲明:
系統版本
[root@CentOS7 ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
確保防火牆及SElinux均為關閉狀態
機器一定要聯網,因為執行./setup的時候會聯網安裝很多的依賴包,安裝速度和你的網速有關
yum源為阿里yum源
二、安裝Ansible
# 安裝epel-release擴展源 [root@CentOS7 ~]# yum -y install epel-release # 安裝ansible [root@CentOS7 ~]# yum -y install ansible # 查看ansible版本 [root@CentOS7 ~]# ansible --version
三、安裝Ansible Tower:
下載tower包
# 安裝curl postgresql [root@CentOS7 ~]# yum -y install vim curl postgresql [root@CentOS7 ~]# mkdir /tmp/tower && cd /tmp/tower 把包上傳到/tmp/tower/下面 [root@CentOS7 ~]# tar xvf ansible-tower-setup-bundle-3.7.0-4.tar.gz # 解壓 [root@CentOS7 ~]# cd ansible-tower-setup-bundle-3.7.0-4.tar.gz # 進入到安裝目錄 [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# mkdir -p /var/log/tower # 創建日志目錄,要不然安裝的時候報錯 # 修改配置文件 [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#password=''#password='admin'#g" inventory #登錄密碼 [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#host=''#host='127.0.0.1'#g" inventory [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#port=''#port='5432'#g" inventory [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# sed -i "s#pg_password=''#pg_password='admin'#g" inventory [root@CentOS7 ansible-tower-setup-bundle-3.7.0-4]# ./setup.sh #腳本執行的過程非常長
四、報錯以及解決方法
第一個報錯
有可能配置文件里面有些必填項你沒有填寫,請看下面
在我的實驗室環境中的CentOS 7上安裝Ansible塔式計算機時,我在安裝過程中發現了一些問題。下載並運行安裝程序時,您會看到以下通知:
任務[飛行前:飛行前檢查-讀取塔式版本] ************************************** ****************************************************** * 致命:[本地主機]:失敗!=> {“已更改”:false,“失敗”:true,“ msg”:“未找到文件:/var/lib/awx/.tower_version”} ...忽略 (...) 任務[預檢:預檢檢查-必須為全新安裝定義密碼] ****************************************************** ******************************************* 致命:[localhost]:失敗!=> {“已更改”:false,“失敗”:true,“ msg”:“請在運行安裝程序之前在清單文件中配置密碼”} 要重試,請使用:--limit @ / home / ansible / ansible-tower-setup-3.1.4 / install.retry
修復很容易。在“清單”文件中提供密碼,然后重新啟動安裝程序。現在,它將使用提供的密碼為您配置滿足所有要求的Ansible,例如Postgres,Supervisord,RabbitMQ和Nginx。
[塔] 本地主機ansible_connection = local [數據庫] [所有:vars] admin_password =' redhat ' #必填 pg_host ='' #必填 pg_port ='' #必填 pg_database ='awx' pg_username ='awx' pg_password =' redhat ' #必填 #需要對fqdns和ip地址為真 rabbitmq_use_long_name = false
第二個錯誤
nginx啟動問題
解決方案:
腳本異常退出之后,你查看一下進程會發現進程是在啟動的狀態,你把他kill掉,手動啟動一下,最后執行以下腳本
五、訪問
等待腳本全部之后訪問
賬戶admin,密碼,開始在配置文件配置的,不知道可以去看看
六、無需申請試用授權文件
1,登錄之后會顯示這個,你可以選擇申請一下,但是不一定能申請成功,也可以選擇下面的方法
2,下面的辦法不行的話,直接把這個干掉就能進來了
mv /var/lib/awx/venv/awx/lib/python3.7/site-packages/tower_license ~
pip3 install uncompyle6
uncompyle6 __init__.pyc >__init__.py
rm -f __init__.pyc __init__.pyo
cd /var/lib/awx/venv/awx/lib/python3.7/site-packages/tower_license vi __init__.py 新增120行, return True 87 def _check_cloudforms_subscription(self): 88 return True
以下摘取license驗證部分代碼
def __init__(self, **kwargs): self._attrs = dict( company_name='', instance_count=0, license_date=0, license_key='UNLICENSED', ) if not kwargs: kwargs = getattr(settings, 'LICENSE', None) or {} self._attrs.update(kwargs) self._attrs['license_date'] = int(self._attrs['license_date']) if not self._attrs.get('subscription_name', None): self._attrs['subscription_name'] = self._generate_subscription_name() if self._check_cloudforms_subscription(): self._generate_cloudforms_subscription() def _generate_cloudforms_subscription(self): self._attrs.update(dict(company_name="Red Hat CloudForms License", instance_count=9999999, license_date=253370764800, license_key='CodyGuo', license_type='enterprise', subscription_name='Red Hat CloudForms License')) def _check_cloudforms_subscription(self): return True if os.path.exists('/var/lib/awx/i18n.db'): return True if os.path.isdir("/opt/rh/cfme-appliance") and os.path.isdir("/opt/rh/cfme-gemset"): try: has_rpms = subprocess.call(["rpm", "--quiet", "-q", "cfme", "cfme-appliance", "cfme-gemset"]) if has_rpms == 0: return True except OSError: pass return False ---------------------
編譯
python3 -m py_compile __init__.py
python3 -O -m py_compile __init__.py
重啟服務
ansible-tower-service restart
except OSError:
pass
return False
編譯 ```css python3 -m py_compile __init__.py python3 -O -m py_compile __init__.py
重啟服務
ansible-tower-service restart
具體用法看官方文檔吧,ansibe tower官方