跳至主要內容
docker搭建Asible测试环境

说明

宿主机需要安装Docker和Docker-compose
创建3个容器:
主机名分别为host1、host2和ansible2.11
host1和host2安装python3.7、openssh server
ansible安装openssh server、openssh client、ansible

步骤

按如下目录结构创建文件

.
├── alpine
│   └── Dockerfile
├── ansible
│   └── Dockerfile
└── docker-compose.yml

运维技巧运维工具运维工具大约 1 分钟
自建yum仓库

安装

yum install -y epel-release
## createrepo和httpd用于创建内网仓库和提供http协议访问
yum install -y createrepo httpd

## 创建本地 YUM 仓库目录 我定义的是repos 你也可以改成其他名称
mkdir -p /var/www/html/repos/{base,extras,updates}

## 上传centos镜像到服务器并挂载然后copy所有软件包到我刚才创建的仓库目录里
mount /dev/cdrom /mnt  # 这个是vmware虚拟机时候用 下边是镜像时候用
# 挂磁盘镜像到/mnt的话执行 mount -o loop CentOS-7-x86_64-DVD-1804.iso /mnt
cp -R /mnt/Packages/* /var/www/html/repos/base
umount /mnt

## 创建本地 YUM 仓库 建立元数据
createrepo /var/www/html/repos/base
createrepo /var/www/html/repos/extras
createrepo /var/www/html/repos/updates

## 修改http配置访问yum仓库
vi /etc/httpd/conf.d/repos.conf
Alias /repos "/var/www/html/repos"

<Directory "/var/www/html/repos">
  Options Indexes FollowSymLinks
  Require all granted
</Directory>

## 启动并开启 httpd 服务
systemctl start httpd
systemctl enable httpd

运维技巧运维工具运维工具大约 1 分钟