chrismeyersfsu.provision_docker
provision_docker
これは、Ansibleの役割をテストするのを助けるためのロールです。あなたのインベントリホストごとに自動的にDockerコンテナを作成します。生産環境のインベントリファイルを使用して、開発とテストのためにDockerコンテナを作成します。
リソース | 説明 |
---|---|
ブログ記事 | provision_docker の使用例 |
.travis.yml | TravisCIの例 |
Dockerfiles | 初期化システムとSSHデーモンを持つキュレーションされたDockerイメージ。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を使用すると、ルーティングルールは必要ありません。
# インベントリ
[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イメージはホスト名に関連付けられたホスト変数である必要があります。 |
| provision_docker_inventory | いいえ | | | Dockerコンテナを立ち上げるための<name, image>ペアのリスト。 |
| provision_docker_use_docker_connection | いいえ | false | true/false | デフォルトのSSHの代わりにDockerコンテナに接続するためにdocker_connectionプラグインを使用します。 |
| 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
を編集します。
ポートの公開と露出
各コンテナに対してインベントリ内の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