基本环境
- 构建UI时需要Docker内存6G以上
官方安装文档
https://github.com/ansible/awx/blob/19.2.2/tools/docker-compose/README.md
安装脚本
#!/bin/bash
# 克隆 awx 项目
if [ ! -d "awx" ]; then
git clone --depth=1 --branch 19.2.2 https://github.com/ansible/awx.git
fi
cd awx
# 恢复Makefile
git restore Makefile
# 停止服务
if [ -f "tools/docker-compose/_sources/docker-compose.yml" ]; then
docker-compose -f tools/docker-compose/_sources/docker-compose.yml down --remove-orphans -v
fi
# 克隆 awx-logos 项目
if [ ! -d "awx-logos" ]; then
git clone --depth=1 --branch master https://github.com/ansible/awx-logos.git
fi
# 修改 Makefile
if [[ "`uname`" = "Darwin" ]]; then
# docker-compose 参数应该在up后面
sed -i '' 's#$(COMPOSE_UP_OPTS) up#up $(COMPOSE_UP_OPTS)#g' Makefile
# 定义 pip 额外源
sed -i '' 's#pip install -r#pip install $(PIP_OPTIONS) -r#g' Makefile
# 定义 PIP_OPTIONS 变量默认值
# macOSX下必须换行
sed -i '' '/GIT_BRANCH/a\
PIP_OPTIONS ?=--extra-index-url=https://pypi.org/simple
' Makefile
# 升级pip
sed -i '' '/$(VENV_BASE)\/awx\/bin\/pip/i\
$(VENV_BASE)\/awx\/bin\/pip install --upgrade pip; \\
' Makefile
else
sed -i 's#$(COMPOSE_UP_OPTS) up#up $(COMPOSE_UP_OPTS)#g' Makefile
sed -i 's#pip install -r#pip install $(PIP_OPTIONS) -r#g' Makefile
sed -i '/GIT_BRANCH/a\PIP_OPTIONS ?=--extra-index-url=https://pypi.org/simple' Makefile
sed -i '/$(VENV_BASE)\/awx\/bin\/pip/i\ $(VENV_BASE)\/awx\/bin\/pip install --upgrade pip; \\' Makefile
fi
# 编译镜像
# make docker-compose-build GIT_BRANCH=19.2.2 DEV_DOCKER_TAG_BASE=seekplum COMPOSE_TAG=19.2.2
# 启动服务
make docker-compose COMPOSE_UP_OPTS=-d GIT_BRANCH=19.2.2 DEV_DOCKER_TAG_BASE=seekplum COMPOSE_TAG=19.2.2
# # 等待一段时间
# sleep 30
# # 清理和构建 UI
# docker exec tools_awx_1 make clean-ui ui-devel
# # 创建管理员用户
# docker exec -it tools_awx_1 awx-manage createsuperuser --noinput --username=awx --email=awx@localhost
# docker exec -it tools_awx_1 awx-manage update_password --username=awx --password=password
# # 加载演示数据
# docker exec tools_awx_1 awx-manage create_preload_data
# 恢复Makefile
git restore Makefile
备份镜像
# 保存容器为镜像
docker commit tools_awx_1 seekplum/awx_devel:19.2.2
# 提交到hub仓库
docker push seekplum/awx_devel:19.2.2