From 841d9cac5b6332253b925c8c79e0aa14e4f1ca6a Mon Sep 17 00:00:00 2001 From: cnphpbb Date: Sun, 27 Apr 2025 15:12:15 +0800 Subject: [PATCH] =?UTF-8?q?build(docker):=20=E6=B7=BB=E5=8A=A0Ansible?= =?UTF-8?q?=E7=9A=84Dockerfile=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加一个新的Dockerfile用于构建Ansible环境,包括安装必要的依赖、配置国内镜像源、创建非root用户以提高安全性,并设置默认入口点 --- ansible/dockerfile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ansible/dockerfile diff --git a/ansible/dockerfile b/ansible/dockerfile new file mode 100644 index 0000000..ae686a7 --- /dev/null +++ b/ansible/dockerfile @@ -0,0 +1,25 @@ +FROM python:3.13.3-alpine +# 使用国内镜像源 +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories + +# 安装必要的依赖 +RUN apk add --no-cache \ + openssh-client \ + sshpass \ + git \ + rsync + +# 安装Ansible及相关工具 +RUN pip install --no-cache-dir \ + ansible \ + ansible-lint \ + jmespath + +# 创建非root用户(安全建议) +RUN adduser -D ansible-user +USER ansible-user +WORKDIR /home/ansible-user + +# 入口点配置 +ENTRYPOINT ["ansible"] +CMD ["--version"] \ No newline at end of file