安装ansible-awx
00 安装ansible-awx
前期准备
ip | os | 用途 |
---|---|---|
192.168.3.213 | CentOS Linux release 7.9.2009 | ansible-awx |
- ansible安装
使用以下脚本install.sh
一键安装:
#!/bin/sh
set -e
is_darwin() {
case "$(uname -s)" in
*darwin* ) true ;;
*Darwin* ) true ;;
* ) false;;
esac
}
get_distribution() {
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"
}
do_install() {
# perform some very rudimentary platform detection
lsb_dist=$( get_distribution )
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
# Run setup for each distro accordingly
export LANG=en_US.UTF-8
case "$lsb_dist" in
ubuntu|debian|raspbian)
sudo apt-get update
#sudo apt-get install -y git python3-pip sshpass build-essential libssl-dev libffi-dev python3-dev
sudo apt-get install -y git sshpass build-essential libssl-dev libffi-dev
#sudo pip3 install -U pip -i https://mirrors.aliyun.com/pypi/simple/ --break-system-packages
sudo pip3 install --no-cache-dir ansible netaddr -i https://mirrors.aliyun.com/pypi/simple/ --break-system-packages
exit 0
;;
centos|fedora|rhel|ol|anolis|kylin)
sudo curl -sSLo /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
sudo yum install -y git python3-pip sshpass libffi-devel python3-devel openssl-devel
sudo pip3 install -U pip -i https://mirrors.aliyun.com/pypi/simple/
sudo pip3 install --no-cache-dir ansible netaddr -i https://mirrors.aliyun.com/pypi/simple/
exit 0
;;
openeuler)
sudo yum install -y git sshpass
sudo pip3 install --no-cache-dir ansible netaddr -i https://mirrors.aliyun.com/pypi/simple/
exit 0
;;
*)
if [ -z "$lsb_dist" ]; then
if is_darwin; then
brew install ./ansible/homebrew-core/ansible.rb
brew install ./ansible/homebrew-core/sshpass.rb
exit 0
fi
fi
echo
echo "ERROR: Unsupported distribution '$lsb_dist'"
echo
exit 1
;;
esac
exit 1
}
do_install
- docker安装
# 卸载当前版本
yum remove docker-ce docker-ce-cli containerd.io -y
# 安装所需依赖
yum install -y yum-utils
# 添加Docker仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 查看可用版本的Docker
yum list docker-ce --showduplicates | sort -r
# 安装特定版本
yum install -y docker-ce-19.03.1 docker-ce-cli-19.03.1-3.el7
# 启动Docker
systemctl start docker
systemctl enable docker
docker version
- 设置镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://docker.fxxk.dedyn.io"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
- python3和pip3安装
sudo yum install -y python3 python3-pip
- 安装 docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
安装awx
# 下载awx包
wget https://github.com/ansible/awx/archive/17.1.0.tar.gz
# 下载完成后,解压;解压完成后进入awx-17.1.0/installer/ 目录下
tar -zxvf 17.1.0.tar.gz
mv awx-17.1.0 /usr/local/
cd /usr/local/awx-17.1.0/installer/
# 查看python3的工作路径并修改inventory文件
which python3
sed -i.bak 's/env python/python/g' inventory
# 下载镜像
docker pull redis
docker pull postgres:12
docker pull ansible/awx:17.1.0
# 修改inventory,把admin_password和project_data_dir注释去掉
admin_user=admin
admin_password=password
project_data_dir=/var/lib/awx/projects
# 安装docker模块
pip3 install docker
pip3 install docker-compose
# ansible执行脚本
ansible-playbook -i inventory install.yml
脚本执行完后,访问网址
因为端口是80,直接访问IP即可。
账号:admin
密码:password
汉化awx
安装14.1.0的版本默认是汉化好的
使用ansible role
一键安装,剧本地址https://github.com/qinzhi1209/Ansible-Role-All/tree/master/roles/ansible-awx
下载代码之后使用如下命令安装:
ansible-playbook -i hosts/hosts.ini -t ansible-awx install_server.yml
如果报错:
ERROR: client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version
那么修改/usr/local/awx/awxcompose/docker-compose.yml
,把version: '2'
改成version: '3'
。
账号:admin
密码:password
喜欢秋天,只因秋知落叶,秋至,叶落。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了