本文简要介绍自动化运维工具Ansible可视化管理平台Ansible Tower。Ansible的自动化运维实现分三部分介绍:
容器云系列之基于Docker的Ansible自动化运维实现——介绍Ansible的基本概念和语法使用
容器云系列之Ansible部署使用——介绍Ansible的安装部署和使用
容器云系列之基于Docker部署Ansible-Tower——介绍使用Docker部署Ansible-Tower
3、基于Docker部署Ansible-Tower
3.1 Tower instance组成
Ansible Tower包括Web服务HTTP Service、通信队列RabbitMQ/Redis、Job作业处理单元Celery Workers和配置信息存储数据库PostgreSQL,如下图所示:
3.2 安装Ansible-Tower
1)下载awx代码
[root@tango-01 tmp]# git clone https://github.com/ansible/awx.git
[root@tango-01 tmp]# cd awx
[root@tango-01 awx]# git clone https://github.com/ansible/awx-logos.git
2)安装相关依赖包
[root@tango-01 installer]# pip3 install docker
[root@tango-01 installer]# pip3 install docker-compose
否则会提示错误信息:
TASK [local_docker : Start the containers] ********************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on tango-01's Python /usr/local/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named 'docker'"}
3)配置inventory
[root@tango-01 installer]# pwd
/tmp/awx/installer
[root@tango-01 installer]# vi inventory
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"
[all:vars]
dockerhub_base=ansible
dockerhub_version=latest
awx_task_hostname=awx
awx_web_hostname=awxweb
postgres_data_dir="/tmp/pgdocker"
host_port=80
host_port_ssl=443
docker_compose_dir="/var/lib/awx"
pg_username=awx
pg_password=password
pg_database=awx
pg_port=5432
admin_user=admin
admin_password=password
project_data_dir=/var/lib/awx/projects
4)docker编译awx
[root@tango-01 installer]# ansible-playbook -i inventory install.yml
PLAY RECAP ****************************************************************************************************************************************************************
localhost : ok=15 changed=4 unreachable=0 failed=0 skipped=91 rescued=0 ignored=0
5)查看结果
[root@tango-01 installer]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7a1329f43d63 ansible/awx:latest "/usr/bin/tini -- /u…" 4 minutes ago Up 3 minutes 8052/tcp awx_task
056943a3889b ansible/awx:latest "/usr/bin/tini -- /b…" 4 minutes ago Up 3 minutes 0.0.0.0:80->8052/tcp awx_web
6bf445df5762 postgres:10 "docker-entrypoint.s…" 4 minutes ago Up 3 minutes 5432/tcp awx_postgres
d66b2caabfc0 redis "docker-entrypoint.s…" 4 minutes ago Up 3 minutes 6379/tcp awx_redis
6)通过浏览器输入http://192.168.112.10:80即可访问AWX
输入用户admin和密码password
参考资料
- https://docs.ansible.com/ansible/latest/user_guide
- http://www.ansible.com.cn/
- https://docs.ansible.com/ansible-tower/3.2.4/html/administration/clustering.html
转载请注明原文地址:https://blog.csdn.net/solihawk/article/details/121958909
文章会同步在公众号“牧羊人的方向”更新,感兴趣的可以关注公众号,谢谢!