由于ansible tower收费,因此考虑使用jenkins+ansible的组合,充分发挥两者的优势,在此将Dockerfile记录下来:
FROM jenkins:2.3
USER root
RUN apt-get update && apt-get install -y curl vim ssh build-essential libssl-dev libffi-dev python-dev python-pip libxml2-dev libxslt1-dev libpq-dev git wget nmap jq
RUN rm -f /etc/apt/sources.list
COPY ./sources.list /etc/apt/sources.list
RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 93C4A3FD7BB9C367
RUN apt-get update
RUN apt-get install -y ansible
RUN pip install xmltodict pywinrm Flask xlsxwriter
EXPOSE 80 443 5432 8080 50000
ENTRYPOINT ["/bin/tini", "--", "/usr/local/bin/jenkins.sh"]
建造命令:
docker build -t jenkins_ansible .
运行命令:
docker run -d -t -v /root/ansible/home:/var/jenkins_home -v /root/.ssh:/root/.ssh --net=host --name ansible jenkins_ansible --httpPort=8082