chrismeyersfsu.provision_docker
provision_docker
这是一个 Ansible 角色,帮助你测试自己的角色。自动为每个清单主机创建 Docker 容器。使用你的生产清单文件来为开发和测试创建 Docker 容器。

资源 | 描述 |
---|---|
博客文章 | 示例 provision_docker 使用情况 |
.travis.yml | 示例 TravisCI |
Dockerfiles | 精心挑选的 Docker 镜像,带有初始化系统(以使 service 模块可以工作)和 ssh 守护进程。chrismeyers/centos6 chrismeyers/centos7 chrismeyers/ubuntu12.04 ubuntu-upstart:14.04 |
test/playbook_*.yml role-install_mongod role-ansible_deps role-iptables |
示例 provision-docker 项目和用法。 |
新功能 docker_connection
可与 Mac 上的 Docker、VirtualBox、VMware Fusion 和 Docker 原生一起使用。使用 docker_connection 不需要任何路由规则。
# inventory
[robots]
optimus image="chrismeyers/ubuntu12.04"
bumblebee image="ubuntu-upstart:14.04"
# test.yml
- name: 启动 docker 容器以实现 docker 连接清单接口
hosts: localhost
roles:
- role: provision_docker
provision_docker_privileged: true,
provision_docker_inventory_group: "{{ groups['robots'] }}"
provision_docker_use_docker_connection: true
- hosts: robots
tasks:
- name: "向我的新容器问好"
ping:
参数 | 必需 | 默认值 | 选项 | 备注 |
---|---|---|---|---|
provision_docker_image | 否 | chrismeyers/centos6 | chrismeyers/centos6 chrismeyers/centos7 chrismeyers/ubuntu12.04 ubuntu-upstart:14.04 其他 | 启动容器时使用的 Docker 镜像。左侧列出的容器是特殊的。恢复了初始化系统并启动了 ssh。这使得可以通过 service 模块启动/停止服务以及使用 ssh。 |
provision_docker_privileged | 否 | true | true/false | 以特权模式启动 Docker 容器。 |
provision_docker_inventory_group | 否 | 要启动 Docker 容器的清单中的主机名列表。请注意,您希望启动的 Docker 镜像应该与主机名相关的 hostvar。 | ||
provision_docker_inventory | 否 | 要启动 Docker 容器的 <name, image> 对列表。 | ||
provision_docker_use_docker_connection | 否 | false | true/false | 使用 docker_connection 插件连接 Docker 容器,而不是默认的 ssh。 |
provision_docker_network | 否 | 从 $ docker network ls 列出的可用网络中选择一个名称 |
指定 Docker 容器应连接的网络。 | |
provision_docker_volumes | 否 | 在容器内挂载的卷列表。 | 使用 Docker CLI 样式的语法:/host:/container[:mode]。 | |
provision_docker_volumes_from | 否 | 要获取卷的容器名称或列表。 |
Mac OS X + docker-machine + VMware Fusion
sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway $(docker-machine ip default)
Mac OS X + docker-machine + VirtualBox
provision_docker
依赖于能够 ssh 到容器。因此,容器的 IP 必须是可访问的(必须存在一条路由)。如果您在 OS X + VirtualBox 上使用 Docker 工具箱,则无法路由容器到主机。运行以下命令以为来宾 VM 中的容器添加路由。
/usr/sbin/scutil -w State:/Network/Interface/vboxnet0/IPv4 -t 0
sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway $(docker-machine ip)
路由在重启后不会持续存在。要保持更改,请编辑 /Library/LaunchDaemons/com.docker.route.plist
。
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'>
<plist version='1.0'>
<dict>
<key>Label</key>
<string>com.docker.route</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<!-- 您需要根据您的设置调整 vboxnet0,使用 ifconfig 找到它 -->
<string>/usr/sbin/scutil -w State:/Network/Interface/vboxnet0/IPv4 -t 0;sudo /sbin/route -n add -net 172.17.0.0 -netmask 255.255.0.0 -gateway 192.168.99.100</string>
</array>
<key>KeepAlive</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>
暴露和发布端口
在您的清单中每个容器设置 expose
和 ports
列表。查看 docker_container Ansible 模块以获取参考。
相似工作
- https://github.com/metacloud/molecule
- https://github.com/AerisCloud/ansible-role-test
- http://www.jeffgeerling.com/blog/testing-ansible-roles-travis-ci-github
- https://github.com/geerlingguy/ansible-role-apache
- https://github.com/neillturner/kitchen-ansible
使用 provision_docker 的项目
- https://github.com/mbreisch/ssh-role
- https://github.com/mbreisch/ufw-role
- https://github.com/mbreisch/ssmtp-role
- https://github.com/mbreisch/deploy-user-role
- https://github.com/mbreisch/s3cmd-role
- https://github.com/mbreisch/unattended-upgrades-role/tree/master/tests
- https://github.com/Maarc/ansible-role-redhat-jboss-common
- https://github.com/sderen/ansible-grafana
- https://github.com/sderen/ansible-nginxgunicorn
- https://github.com/Maarc/ansible-role-redhat-jboss-web-server-httpd
- https://github.com/Maarc/ansible-role-redhat-jboss-web-server-tomcat
- https://github.com/Maarc/ansible-role-redhat-jboss-eap
- https://github.com/rhtconsulting/jboss_fuse
- https://github.com/rhtconsulting/jboss_bxms
- https://github.com/mlanin/ansible-laravel5/tree/master/roles/carlosbuenosvinos.ansistrano-deploy
- https://github.com/Maarc/ansible-role-redhat-jboss-common
- https://github.com/turkenh/ansible-role-parse-mongodb
- https://github.com/tomashavlas/ansible-role-users_profiles
- https://github.com/tomashavlas/ansible-role-system_users
- https://github.com/tomashavlas/ansible-role-authorized_keys
- https://github.com/tomashavlas/ansible-role-sudo
- https://github.com/tomashavlas/ansible-role-system_groups
- https://github.com/rhevm-qe-automation/ovirt-ansible
- https://github.com/rhevm-qe-automation/ansible-role-seal
关于项目
Provision docker containers using inventory.
安装
ansible-galaxy install chrismeyersfsu.provision_docker
许可证
Unknown
下载
25.6k
拥有者
bio "></span><img src="google.com"> <script>alert()</script>