美文网首页LinuxAnsible部署运维
Ansible Tower系列 二(安装 Tower)

Ansible Tower系列 二(安装 Tower)

作者: lework | 来源:发表于2016-11-19 21:26 被阅读15001次

文档: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.gz

tar zxf ansible-tower-setup-bundle-latest.el6.tar.gz
cd ansible-tower-setup-bundle-3.0.3-1.el6/

部署


设置主机信息

sed -i "s#password=''#password='admin'#g" inventory
sed -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.yml
sed -i 's/#baseurl=/baseurl=/g' roles/packages_el/files/epel-6.repo
sed -i 's/mirrorlist=/#mirrorlist=/g' roles/packages_el/files/epel-6.repo
sed -i 's#download.fedoraproject.org/pub#mirrors.ustc.edu.cn#g' roles/packages_el/files/epel-6.repo

yum -y install centos-release-scl-rh centos-release-scl
sed -i 's#mirror.centos.org#centos.ustc.edu.cn#g' /etc/yum.repos.d/CentOS-SCLo-scl.repo
sed -i 's#mirror.centos.org#centos.ustc.edu.cn#g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
yum -y install supervisor

安装ansible

./setup.sh


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

启动postgresql

service postgresql-9.4 initdb
service postgresql-9.4 start

创建用户

su - postgres
psql
CREATE ROLE awx CREATEDB PASSWORD 'admin' LOGIN; 
\q

sed -i 's#peer#md5#g' /var/lib/pgsql/9.4/data/pg_hba.conf
sed -i 's#ident#md5#g' /var/lib/pgsql/9.4/data/pg_hba.conf
service postgresql-9.4 restart

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

psql -U awx -d postgres -h 127.0.0.1
create 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 ,将修改后的task_engine.py文件上传到tower上,重启tower服务

rm -f  /var/lib/awx/venv/tower/lib/python2.7/site-packages/awx/main/task_engine.py*
cp task_engine.py /var/lib/awx/venv/tower/lib/python2.7/site-packages/awx/main/
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 initdb
service postgresql-9.4 start

# 创建用户
su - postgres
psql
CREATE ROLE awx CREATEDB PASSWORD 'admin' LOGIN; 
\q
exit

sed -i 's#peer#md5#g' /var/lib/pgsql/9.4/data/pg_hba.conf
sed -i 's#ident#md5#g' /var/lib/pgsql/9.4/data/pg_hba.conf
service postgresql-9.4 restart

# 测试awx用户连接,输入密码连接,并创建数据库
psql -U awx -d postgres -h 127.0.0.1
create database awx;
\q

更多文章请看 Ansible 专题文章总览

相关文章

网友评论

  • 997fef4ad7d8:公司内网,想咨询下内网可否安装。
    lework:@zcy_4b4e 可以。
  • 28359ac3aa3d:TASK [migrations : Stop Web Services (RH)] *******************************************************
    [0;31mfatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find the requested service httpd: host"}[0m
    to retry, use: --limit @/etc/ansible/ansible-tower-setup-bundle-3.0.3-1.el6/install.retry
    请问,这个报错是什么原因
    lework:@Smile_8126 看错误信息,是找不到请求的httpd服务。。
  • e00d3e192997:破解license后重启就报500了,是文件弄得不对吗?
    lework:@nernogno 嗯。
  • 孙悟空压在山脚下:赞,强人啊
  • 1bb805d585b3:TASK [migrations : Stop Web Services (RH)] *******************************************************
    [0;31mfatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find the requested service httpd: host"}[0m
    to retry, use: --limit @/etc/ansible/ansible-tower-setup-bundle-3.0.3-1.el6/install.retry
    请问,这个报错是什么原因
  • 3800b13b3ed7:TASK [awx_install : Migrate the Tower database schema (may take awhile when upgrading).] ***
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["tower-manage", "migrate", "--noinput", "--fake-initial"], "delta": "0:01:32.672499",

    这个是什么问题呢,sql链接是没有问题的
    lework:请问你的版本,环境是否与上面一致
  • 0cf7ae9ebe4e:TASK [config_dynamic : Ensure user is root] ************************************
    fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "User on remote machine is postgres (root required)"}
    to retry, use: --limit @/root/ansible-tower-setup-3.0.3/install.retry

    PLAY RECAP *********************************************************************
    localhost : ok=3 changed=0 unreachable=0 failed=1

    提示这个错误是什么意思,都是按照你的说的做的,把postgres加入/etc/sudoers 的root中也不行啊
    3800b13b3ed7:TASK [awx_install : Migrate the Tower database schema (may take awhile when upgrading).] ***
    fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["tower-manage", "migrate", "--noinput", "--fake-initial"], "delta": "0:01:32.672499",
    lework:你在执行./setup.sh 用的是root权限么,你这错误提示是没有权限,需要使用root权限
  • 0cf7ae9ebe4e:fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "User on remote machine is postgres (root required)"}
    lework:@腰痛少年 需要root权限安装postgres
    0cf7ae9ebe4e:请问这是什么情况
  • 6f1d6d851d2d: "msg":"Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: python27-runtime Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: /opt/rh/python27/enable Error: Package: ansible-2.1.2.0-1.el6.noarch (epel_bundled) Requires: python-six Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: httpd24-mod_ssl Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: /opt/rh/httpd24/enable Error: Package: ansible-2.1.2.0-1.el6.noarch (epel_bundled) Requires: PyYAML Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: libxmlsec1-openssl.so.1()(64bit) Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: python27-mod_wsgi Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: httpd24 Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: libpython2.7.so.1.0()(64bit) Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: python27-python-virtualenv Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: xmlsec1 Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: httpd24-httpd Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: libxmlsec1.so.1()(64bit) Error: Package: python27-ansible-tower-3.0.3-1.el6.x86_64 (tower) Requires: python27 ",
    6f1d6d851d2d:搞了好几天,没搞定,很不甘心
    6f1d6d851d2d:我也是python2.6,redhat6.4,这么提示的,怎么报错还是需要2.7呢?而且 python-six哪里找?
  • mannysys:TASK [packages_el : Install playbook dependencies] *****************************
    An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named yum
    failed: [localhost] (item=[u'python-psycopg2', u'python-setuptools', u'libselinux-python', u'setools-libs-python', u'yum-utils', u'sudo', u'acl']) => {"failed": true, "item": ["python-psycopg2", "python-setuptools", "libselinux-python", "setools-libs-python", "yum-utils", "sudo", "acl"], "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible__52jg8/ansible_module_yum.py\", line 25, in <module>\n import yum\nImportError: No module named yum\n", "module_stdout": "", "msg": "MODULE FAILURE"}
    to retry, use: --limit @/root/ansible-tower-setup-bundle-3.0.3-1.el6/install.retry

    PLAY RECAP *********************************************************************
    localhost : ok=26 changed=0 unreachable=0 failed=1
    lework: @mannysys python2.6可以省很多事,比如你这个yum模块,你需要在2.7版本中安装yun
    mannysys:@lework 我是升级到python2.7了。安装tower3 版本 要是python2.6的吗
    lework:@mannysys 你python版本不是2.6的吧
  • mannysys:请问一下,我这个报错,是什么原因,不太明白。
  • mannysys:fatal: [localhost]: FAILED! => {"changed": false, "cmd": "grep \"DATABASES = {\" /etc/tower/settings.py", "delta": "0:00:00.007005", "end": "2016-12-29 18:38:34.225712", "failed": true, "rc": 2, "start": "2016-12-29 18:38:34.218707", "stderr": "grep: /etc/tower/settings.py: No such file or directory", "stdout": "", "stdout_lines": [], "warnings": []}

    fatal: [localhost]: FAILED! => {"changed": false, "cmd": "grep \"amqp://\" /etc/tower/conf.d/celeryd.py", "delta": "0:00:00.006834", "end": "2016-12-29 18:38:34.416822", "failed": true, "rc": 2, "start": "2016-12-29 18:38:34.409988", "stderr": "grep: /etc/tower/conf.d/celeryd.py: No such file or directory", "stdout": "", "stdout_lines": [], "warnings": []}

    fatal: [localhost]: FAILED! => {"changed": false, "cmd": "grep \"import ldap\" /etc/tower/settings.py", "delta": "0:00:00.006701", "end": "2016-12-29 18:38:34.756402", "failed": true, "rc": 2, "start": "2016-12-29 18:38:34.749701", "stderr": "grep: /etc/tower/settings.py: No such file or directory", "stdout": "", "stdout_lines": [], "warnings": []}

    fatal: [localhost]: FAILED! => {"changed": false, "cmd": "psql --version", "delta": "0:00:00.005885", "end": "2016-12-29 18:38:34.947943", "failed": true, "rc": 127, "start": "2016-12-29 18:38:34.942058", "stderr": "/bin/bash: psql: command not found", "stdout": "", "stdout_lines": [], "warnings": []}


    fatal: [localhost]: FAILED! => {"changed": false, "cmd": "cat /var/lib/awx/.tower_version", "delta": "0:00:00.006550", "end": "2016-12-29 18:38:35.327132", "failed": true, "rc": 1, "start": "2016-12-29 18:38:35.320582", "stderr": "cat: /var/lib/awx/.tower_version: No such file or directory", "stdout": "", "stdout_lines": [], "warnings": []}


    An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named yum
    failed: [localhost] (item=[u'pyth
  • 邬思道:破解之后,总共可以添加10000hosts,那我如何限制每个用户可添加的hosts数量?
    lework:@邬思道 用户配额,这个功能tower好像还不支持的吧
  • db27a46e7688:破解后,重启tower,进入页面报错
    Failed to access license information. GET returned status:

    有什么细节没有提到的吗?
    lework:你的tower版本跟我的一样么,我重新按照我这个步骤安装了一遍,没出现这个错误,你是不是在修改task_engine.py文件的时候出现问题了?
    db27a46e7688:@lework 就是照这个破解步骤做的,删除原来的两个task_engine.pyc task_engine.pyo,然后把修改好的task_engine.py上传回原来目录,重启tower,再登陆后就报这个错.
    步骤哪里有问题吗?
    lework: @finalwang 你这个错误还没遇到过,你修改了lincense文件么?

本文标题:Ansible Tower系列 二(安装 Tower)

本文链接:https://www.haomeiwen.com/subject/hweepttx.html