首页 > 代码库 > Ansible Tower系列 二(安装 Tower)【转】

Ansible Tower系列 二(安装 Tower)【转】

文档:http://docs.ansible.com/ansible-tower/

安装前检查


  1. python版本为2.6
  2. 保持网络畅通
  3. 内存预留充足
  4. 安装用户为root

软件下载


下载地址:http://releases.ansible.com/ansible-tower/setup/
含有包文件的版本:http://releases.ansible.com/ansible-tower/setup-bundle/

wget http://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-latest.el6.tar.gztar zxf ansible-tower-setup-bundle-latest.el6.tar.gzcd ansible-tower-setup-bundle-3.0.3-1.el6/

部署


设置主机信息

sed -i "s#password=‘‘#password=‘admin‘#g" inventorysed -i "s#host=‘‘#host=‘127.0.0.1‘#g" inventory sed -i "s#port=‘‘#port=‘5432‘#g" inventory

修改yum源

sed -i ‘s#dl.fedoraproject.org/pub#mirrors.ustc.edu.cn#g‘ roles/packages_el/defaults/main.ymlsed -i ‘s/#baseurl=/baseurl=/g‘ roles/packages_el/files/epel-6.reposed -i ‘s/mirrorlist=/#mirrorlist=/g‘ roles/packages_el/files/epel-6.reposed -i ‘s#download.fedoraproject.org/pub#mirrors.ustc.edu.cn#g‘ roles/packages_el/files/epel-6.repoyum -y install centos-release-scl-rh centos-release-sclsed -i ‘s#mirror.centos.org#centos.ustc.edu.cn#g‘ /etc/yum.repos.d/CentOS-SCLo-scl.reposed -i ‘s#mirror.centos.org#centos.ustc.edu.cn#g‘ /etc/yum.repos.d/CentOS-SCLo-scl-rh.repoyum -y install supervisor`

安装ansible

./setup.sh


TASK [awx_install : Migrate the Tower database schema (may take awhile when upgrading).] ***
这一步会出现错误,提示信息是数据库连接不上

启动postgresql

service postgresql-9.4 initdbservice postgresql-9.4 start

创建用户

su - postgrespsqlCREATE ROLE awx CREATEDB PASSWORD ‘admin‘ LOGIN; \qsed -i ‘s#peer#md5#g‘ /var/lib/pgsql/9.4/data/pg_hba.confsed -i ‘s#ident#md5#g‘ /var/lib/pgsql/9.4/data/pg_hba.confservice postgresql-9.4 restart

测试awx用户连接,输入密码连接,并创建数据库

psql -U awx -d postgres -h 127.0.0.1create database awx;\q

再次./setup.sh进行安装tower

Web配置


访问web页面

https://192.168.77.128/#/

技术分享
Paste_Image.png

用户名/密码为admin admin

导入license
没有的话,点击REQUEST LICENSE,去官方申请免费试用。

技术分享
Paste_Image.png

提交license后,就进入了DASHBOARD页面啦

技术分享
Paste_Image.png

Tower无限hosts的License修改


仅供实验测试使用,切勿挪作他用。

下载反编译工具: http://sourceforge.net/projects/easypythondecompiler/

反编译task_engine.pyc文件

find / -name task_engine.pyc/var/lib/awx/venv/tower/lib/python2.7/site-packages/awx/main/task_engine.pyc
技术分享
Paste_Image.png

反编译后的文件为task_engine.pyc_dis,文件重命名为task_engine.py

修改内容

89行和186行代码
available_instances = int(self.attributes[‘instance_count‘]) 为
available_instances = 10000

技术分享
Paste_Image.png
技术分享
Paste_Image.png

247行代码,把相应的功能由False改为True(这步未实施

技术分享
Paste_Image.png

删除task_engine.pyc task_engine.pyo 重启tower

rm -f  /var/lib/awx/venv/tower/lib/python2.7/site-packages/awx/main/task_engine.py*ansible-tower-service restart

查看license信息

技术分享
Paste_Image.png

安装时遇到的错误


fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "This machine does not have sufficient RAM to run Ansible Tower."}

解决:机器内存不足,增加内存

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "no service or tool found for: supervisord"}

解决:yum -y install supervisor

出现Is the server running on host \"localhost\" (127.0.0.1) and accepting\n\tTCP/IP connections on port 5432?

是postgresql服务没启动

service postgresql-9.4 initdbservice postgresql-9.4 start# 创建用户su - postgrespsqlCREATE ROLE awx CREATEDB PASSWORD ‘admin‘ LOGIN; \qexitsed -i ‘s#peer#md5#g‘ /var/lib/pgsql/9.4/data/pg_hba.confsed -i ‘s#ident#md5#g‘ /var/lib/pgsql/9.4/data/pg_hba.confservice postgresql-9.4 restart# 测试awx用户连接,输入密码连接,并创建数据库psql -U awx -d postgres -h 127.0.0.1create database awx;\q

 参考

centos6.5安装自动化工具ansible和图形化工具tower - xiaoxiaozhou - 51CTO技术博客

http://xiaoxiaozhou.blog.51cto.com/4681537/1888754

 

ansible&Tower无限hosts的License修改方法 - Tower应用 - 51CTO技术博客

http://tower.blog.51cto.com/3711105/1701339/

Ansible Tower系列 二(安装 Tower)【转】