forked from DevOps/deploy.stack
build(ansible): 添加env.cfg和docker-compose.yml文件并更新dockerfile
添加env.cfg文件用于配置镜像标签,docker-compose.yml文件用于定义Ansible服务容器。更新dockerfile以优化依赖安装和容器入口点配置,确保容器运行更高效和安全。
This commit is contained in:
19
ansible/docker-compose.yml
Normal file
19
ansible/docker-compose.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
# DEPLOY:: docker compose -p base --env-file ./ansible/env.cfg -f ./ansible/docker-compose.yml up -d
|
||||
services:
|
||||
ansible:
|
||||
image: ${IMAGE_TAG}
|
||||
volumes:
|
||||
- ~/.ssh:/home/ansible-user/.ssh
|
||||
- ./ansible.cfg:/etc/ansible/ansible.cfg
|
||||
- ./ansible_hosts:/etc/ansible/hosts
|
||||
- ~/playbooks:/home/ansible-user/playbooks
|
||||
environment:
|
||||
- ANSIBLE_HOST_KEY_CHECKING=False
|
||||
tty: true
|
||||
stdin_open: true
|
||||
networks:
|
||||
- ansible-net
|
||||
|
||||
networks:
|
||||
ansible-net:
|
||||
driver: bridge
|
||||
@@ -1,19 +1,21 @@
|
||||
# BUILD:: docker buildx build --platform linux/amd64 -t hub.tp229.com:3500/ansible-alpine:py3.13-rootless .
|
||||
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 \
|
||||
RUN apk add --update --no-cache \
|
||||
openssh-client \
|
||||
sshpass \
|
||||
bash \
|
||||
git \
|
||||
rsync
|
||||
|
||||
# 安装Ansible及相关工具
|
||||
RUN pip install --no-cache-dir \
|
||||
-i https://mirrors.ustc.edu.cn/pypi/simple \
|
||||
ansible \
|
||||
ansible-lint \
|
||||
jmespath
|
||||
ansible-lint
|
||||
|
||||
# 创建非root用户(安全建议)
|
||||
RUN adduser -D ansible-user
|
||||
@@ -21,5 +23,5 @@ USER ansible-user
|
||||
WORKDIR /home/ansible-user
|
||||
|
||||
# 入口点配置
|
||||
ENTRYPOINT ["ansible"]
|
||||
CMD ["--version"]
|
||||
ENTRYPOINT []
|
||||
CMD ["ansible", "--version"]
|
||||
1
ansible/env.cfg
Normal file
1
ansible/env.cfg
Normal file
@@ -0,0 +1 @@
|
||||
IMAGE_TAG=hub.tp229.com:3500/ansible-alpine:py3.13-rootless
|
||||
Reference in New Issue
Block a user