Container sig#1 ansible-container

786 views

Published on

Presented at Container SIG Meet-up 2016 Fall.
<http: />

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
786
On SlideShare
0
From Embeds
0
Number of Embeds
387
Actions
Shares
0
Downloads
9
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Container sig#1 ansible-container

  1. 1. 1 Container-SIG#1 10/7/2016 Naoya Hashimoto Ansible Container
  2. 2. Table of contents • What is Ansible Container? • Why Ansible Container Project begins? • How to use ansible-container? • Ansible Container Demonstration 2
  3. 3. Ansible Container? 3
  4. 4. ansible-container shipit push build run build, run, push and shipit init
  5. 5. docker-compose? 5
  6. 6. Feature • Docker ImageのビルドはDockerfileからPlaybookへ • Playbook=Ansible Moduleでビルド/デプロイ • PlaybookはYAML形式、docker-composeユーザに優しい 6
  7. 7. ansible-container init (ver 0.1) 7 $ ansible-container init $ tree ansible ansible/ ├── container.yml ├── main.yml └── requirements.txt
  8. 8. ansible-container init 8 container.yml • Dockerfileやdocker-compose.ymlに相当 • Imageやバージョン、マップするポート、環境変数などを定義 main.yml • Master Playbook (site.yml)に相当 • イメージをビルドする際に実行するAnsibleのRoleやTaskを定義 • container.ymlが自動で生成したインベントリを参照 requirements.txt • イメージをビルドする際に必要なPythonライブラリを定義 • pipのフォーマットに準拠
  9. 9. ansible-container init (ver 0.2) 9 $ ansible-container init $ tree ansible ansible/ ├── ansible.cfg ├── container.yml ├── main.yml ├── meta.yml ├── requirements.txt └── requirements.yml
  10. 10. Why Ansible Container Project begins? 10
  11. 11. Ansible Container Project “5 REASONS WE STARTED THE ANSIBLE CONTAINER PROJECT” https://www.ansible.com/blog/ansible-container-project 1. Because our community has been using Ansible to manage containers for quite a while now. 2. Because the new Docker connection plug-in makes it far simpler to run Ansible against a Docker container. 3. Because shell scripts aren’t good enough. 4. Because Ansible can be a great bridge to larger-scale container orchestration. 5. Because we believe that communities make the best software. 11
  12. 12. Ansible Community & Docker Docker ContainerをPlaybookで管理 • Docker Hubに公開しているAnsibleのイメージは約1,000件に • メンバーが様々なDocker ContainerのベストプラクティスをBlog に公開 • 集約されたナレッジをツールとして開発する流れに Docker Moduleや機能を拡張 • Docker ModuleがAnsible Moduleの中で最も利用される • Connection PluginにDocker Connection Pluginをリリース • 初期のDocker ModuleはDeprecated https://docs.ansible.com/ansible/guide_docker.html • 2.2からdocker_containerやdocker_imageに置き換え https://github.com/ansible/ansible-modules- core/blob/devel/cloud/docker/_docker.py 12
  13. 13. Ansible Docker Modules & Plugins 13 Version Module/Plugin Feature 1.4 (2013) docker (Deprecated) Docker Moduleのオリジナル docker build, load, pull, push, tagなどに相当 1.6 Dynamic Inventory Docker ContainerのInventoryを動的に生成 2.0 Docker Connection Docker Containerにsshを利用せずに接続 2.0 docker_login docker login に相当 2.1 docker_service docker-composeに相当, version 1, 2に対応 2.1 docker_container Docker Containerをデプロイ 2.1 docker_image_facts Docker HostでキャッシュしたDockerイメージを Inspect, Factsなどに利用 2.2 (2016) docker_network docker network に相当
  14. 14. Docker Connection Plugin 14 Ansible 2.1でDocker Connection Pluginをリリース • Connection DriverにDocker Connection Pluginを指定 • Playbookの実行にdocker execを利用 • PlaybookはVM, Containerで互換性を保てる? 2.1 sshd app app
  15. 15. End the bash madness 15 "Ansible Container represents an end to the command && command && command (and so on) syntax you’ve been struggling with to build containers.” https://www.ansible.com/ansible-container # grab tini for signal processing and zombie killing ENV TINI_VERSION v0.9.0 RUN set -x && curl -fSL "https://$URI/$TINI_VERSION/tini" -o /usr/local/bin/tini && curl -fSL "https://$URI/$TINI_VERSION/tini.asc" -o /usr/local/bin/tini.asc && export GNUPGHOME="$(mktemp -d)" && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 && gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini && rm -r "$GNUPGHOME" /usr/local/bin/tini.asc && chmod +x /usr/local/bin/tini && tini -h
  16. 16. How to use ansible-container? 16
  17. 17. Usage: $ ansible-container --help 17 Command Docker Command Feature init ansible-garaxy init テンプレートを生成 build docker build docker-compose build Docker Imageをビルド run docker run docker-compose up Docker Containerを起動 push docker push Docker RegistryにImageを プッシュ shipit oc new-app oc run オーケストレーション環境に デプロイ e.g. Kubernetes, OpenShift
  18. 18. Ansible Container Examples 18 https://github.com/ansible/ansible-container-examples
  19. 19. Demonstration 19
  20. 20. build & run 20 Prerequisites • Python 2.7 • pip • setuptools 20.0.0+ • Docker 1.11 or access to a Docker daemon. Installation $ sudo pip install ansible-container $ ansible-container version Build & Run $ git clone https://github.com/ansible/ansible-container-examples.git $ cd ansible-container-examples/ ; cp -r helloworld-nginx/ ansible $ ansible-container build $ ansible-container run –d $ ansible-container stop Push $ docker login $ ansible-container push
  21. 21. Reference 21 Ansible Container https://github.com/ansible/ansible-container Documentation https://www.ansible.com/ansible-container ansible-container-examples https://github.com/ansible/ansible-container-examples 5 REASONS WE STARTED THE ANSIBLE CONTAINER PROJECT https://www.ansible.com/blog/ansible-container-project 6 WAYS ANSIBLE MAKES DOCKER-COMPOSE BETTER https://www.ansible.com/blog/six-ways-ansible-makes-docker-compose- better ANSIBLE AND CONTAINERS: WHY AND HOW https://www.ansible.com/blog/ansible-and-containers-why-and-how
  22. 22. Q&A 22

×