1.前期准备
ansible安装
docker安装
python3和pip3安装
sudo yum install python3 python3-pip
安装 docker-compose 的Python模块,有两种方式
1)二进制安装
[root@localhost /]# curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose [root@localhost /]# chmod +x /usr/local/bin/docker-compose
2)pip3安装
[root@localhost /]# pip3 install docker-compose
在安装的过程中碰到尝试安装cryptography
库时遇到的。错误消息指出setuptools_rust
模块未找到,这通常是因为该模块未安装。setuptools_rust
是一个Python包,用于将Rust代码编译为Python扩展。它是cryptography
库的依赖项之一。
解决:
-
首先,确保您的pip是最新版本。可以使用以下命令进行升级:
pip install --upgrade pip
-
接下来,安装
setuptools_rust
:
pip install setuptools_rust
-
然后,再次尝试安装
cryptography
:
pip install cryptography
执行完后,再重新安装一遍。验证是否成功安装
[root@localhost ~]# docker-compose --version /usr/local/lib/python3.6/site-packages/paramiko/transport.py:32: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore,
support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6. from cryptography.hazmat.backends import default_backend docker-compose version 1.29.2, build unknown
2.安装awx
2.1 下载awx包,地址:https://github.com/ansible/awx/archive/14.1.0.tar.gz
[root@localhost awx]# wget https://github.com/ansible/awx/archive/14.1.0.tar.gz --2023-09-27 00:18:03-- https://github.com/ansible/awx/archive/14.1.0.tar.gz 正在解析主机 github.com (github.com)... 20.205.243.166 正在连接 github.com (github.com)|20.205.243.166|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 302 Found 位置:https://codeload.github.com/ansible/awx/tar.gz/refs/tags/14.1.0 [跟随至新的 URL] --2023-09-27 00:18:03-- https://codeload.github.com/ansible/awx/tar.gz/refs/tags/14.1.0 正在解析主机 codeload.github.com (codeload.github.com)... 20.205.243.165 正在连接 codeload.github.com (codeload.github.com)|20.205.243.165|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:未指定 [application/x-gzip] 正在保存至: “14.1.0.tar.gz” [ <=> ] 11,810,343 299KB/s 用时 36s 2023-09-27 00:18:40 (323 KB/s) - “14.1.0.tar.gz” 已保存 [11810343]
2.2 下载完成后,解压;解压完成后进入awx-14.1.0/installer/ 目录下
[root@localhost awx]# tar -zxvf 14.1.0.tar.gz
[root@localhost awx]# ll 总用量 11540 -rw-r--r--. 1 root root 11810343 9月 27 00:18 14.1.0.tar.gz drwxrwxr-x. 11 root root 4096 8月 25 2020 awx-14.1.0
2.3 查看python3的工作路径并修改inventory文件
[root@localhost installer]# which python3 /usr/bin/python3 [root@localhost installer]# sed -i.bak 's/env python/python/g' inventory
2.4 下载镜像
[root@localhost installer]# docker pull redis:latest [root@localhost installer]# docker pull postgres:10 [root@localhost installer]# docker pull ansible/awx:14.1.0
查看镜像:
[root@localhost installer]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest da63666bbe9a 6 days ago 138MB postgres 10 1cad456b3a24 15 months ago 202MB ansible/awx 14.1.0 8a29b4e35f5f 3 years ago 1.3GB
ansible执行脚本
[root@localhost installer]# ansible-playbook -i inventory install.yml
在安装过程中报的错:
1)防火墙添加规程时报错
docker: Error response from daemon: driver failed programming external connectivity on endpoint test-01
(8d72c882bcfb557f9e9b2db6a9403793994a43a70100faeec35a02a24e1031ae): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 81 -j DNAT
--to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name. (exit status 1)).
解决:启动防火墙再重新安装。
2)libselinux-python 没有安装
failed: [localhost] (item={u'mode': u'0600', u'file': u'environment.sh'}) => {"ansible_loop_var": "item", "changed": false, "checksum":
"18957af76126a0769a3d66e4e5a62ff17144eed2", "item": {"file": "environment.sh", "mode": "0600"}, "msg": "Aborting, target uses selinux but
python bindings (libselinux-python) aren't installed!"}
解决:安装libselinux-python
sudo yum install libselinux-python3
安装完成后,再重新执行脚本。
3)端口冲突
fatal: [localhost]: FAILED! => {"changed": false, "errors": [], "module_stderr": "Creating awx_redis ... \nCreating awx_postgres ... \nCreating awx_redis
... done\nCreating awx_postgres ... done\nCreating awx_web ... \nHost is already in use by another container\nCreating awx_web
... error\n", "module_stdout": "", "msg": "Error starting project Encountered errors while bringing up the project."}
解决:
[root@localhost installer]# docker inspect awx_web
看到是80端口已经被使用,查看端口的使用情况,并杀掉
[root@localhost installer]# sudo lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 9211 root 4u IPv6 60850 0t0 TCP *:http (LISTEN) httpd 9280 apache 4u IPv6 60850 0t0 TCP *:http (LISTEN) httpd 9284 apache 4u IPv6 60850 0t0 TCP *:http (LISTEN) httpd 9290 apache 4u IPv6 60850 0t0 TCP *:http (LISTEN) httpd 9301 apache 4u IPv6 60850 0t0 TCP *:http (LISTEN) httpd 9307 apache 4u IPv6 60850 0t0 TCP *:http (LISTEN)
并用kill -9 pid 杀掉相关进程
2.5 脚本执行完后,访问网址
因为端口是80,直接访问IP即可。
账号:admin
密码:password
标签:github,awx,ansible,可视化,docker,root,localhost From: https://www.cnblogs.com/joyware/p/17733228.html