此篇文件写的是在Kubernetes1.5中安装ansible.
这里使用的是Centos6.8来安装ansible。
[root@6ca3bdb01ed1 ~]# cat /etc/issue
CentOS release 6.8 (Final)
Kernel \r on an \m
下载安装包:
yum install -y wget
wget http://releases.ansible.com/ansible-tower/setup-bundle/ansible-tower-setup-bundle-latest.el6.tar.gz
tar -xvzf 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
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
安装supervisor
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
异常处理
如果安装时出现The file system mounted at / does not meet minimum disk space requirement: 9063067648 < 10000000000”}
则找到以文件:ansible-tower-setup-bundle-3.0.3-1.el6/roles/preflight/tasks/main.yml
注释以下内容:
#- name: Preflight check - Does /var meet minimum disk space requirement
# fail:
# msg: 'The file system mounted at {{ item.mount }} does not meet minimum disk space requirement: {{ item.size_available }} < {{ minimum_var_space }}'
# when: "item.mount == var_partition.stdout and item.size_available < minimum_var_space|int"
# with_items: "{{ ansible_mounts }}"
如果出现错误
TASK [awx_install : Migrate the Tower database schema (may take awhile when upgrading).] ***
提示数据库连接不上。执行下面命令启动数据库
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
接下来访问web页面
刚开始已经把443映射到了9443:
docker run -i --name "ansible-tower" -p 55121:22386 -p 9080:80 -p 9443:443 -d -t centos_ssh /usr/sbin/sshd -D
申请完后需要等待一会才会收到 key的邮件。
收到邮件以后,上传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
反编译后的文件为task_engine.pyc_dis,文件重命名为task_engine.py
修改内容
89行和186行代码
available_instances = int(self.attributes[‘instance_count’]) 为
available_instances = 10000
247行代码,把相应的功能由False改为True
删除task_engine.pyc task_engine.pyo 重启tower
查看license信息
以后在镜像中已经将Ansible-tower安装完成。在接下来将对镜像做适当的修改。
查看docker运行情况
[root@localhost credit]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6ca3bdb01ed1 centos_ssh "/usr/sbin/sshd -D" 4 hours ago Up 4 hours 0.0.0.0:9080->80/tcp, 0.0.0.0:9443->443/tcp, 0.0.0.0:55121->22/tcp ansible-tower
保存窗口为镜像:
docker commit 6ca3bdb01ed1 ansible-tower:0.1