Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
プレイブックの検証環境をdocker-composeで作った話/playbook tes...
Search
あんでぃー
February 12, 2020
Technology
890
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
プレイブックの検証環境をdocker-composeで作った話/playbook test environment by docker-compose
あんでぃー
February 12, 2020
More Decks by あんでぃー
See All by あんでぃー
AnsibleでVSCode拡張を管理しちゃおう!/why dont you manage vscode extension with Ansible?
answerd
2
800
なぜSIerは自動化するのか/Why do SIers automate?
answerd
0
190
Other Decks in Technology
See All in Technology
AI 不只幫你寫 Code: 當專案從 300 暴增到 1500, 我們如何撐住 DevOps
appleboy
0
150
事業会社における 機械学習・推薦システム技術の活用事例と必要な能力 / ml-recsys-in-layerx-wantedly-2026
yuya4
0
160
水を運ぶ人としてのリーダーシップ
izumii19
4
900
Claude Codeをどのように キャッチアップしているか
oikon48
13
8.8k
Kiro Ambassador を目指す話
k_adachi_01
0
120
サイバーエージェントにおけるAI推進戦略と変革への取り組み
shotatsuge
0
460
千葉での単身赴任からAWSをやり続け、千葉に戻ってきた話
yama3133
1
110
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
180
スタートアップにAmazon EKSは早すぎる? マルチプロダクト戦略を加速する Platform Engineeringの実践 / Is Amazon EKS Too Soon for Startups? Practical Platform Engineering to Accelerate a Multi-Product Strategy
elmodev09
1
1.7k
感情と身体を置き去りにしない、エンジニアの生きのこり方 ──いまから、ここから「自分の状態」を扱うという選択
saorimurooka
0
300
Comment regagner la souveraineté de vos données tout en étant payé grâce à Nostr !
rlifchitz
0
180
自宅LLMの話
jacopen
1
710
Featured
See All Featured
Building Applications with DynamoDB
mza
96
7.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Ruling the World: When Life Gets Gamed
codingconduct
0
260
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
Believing is Seeing
oripsolob
1
150
The Curse of the Amulet
leimatthew05
2
13k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
310
Visualization
eitanlees
152
17k
Transcript
ϓϨΠϒοΫͷݕূڥΛ docker-composeͰ࡞ͬͨ ͋ΜͰ͌ʔ @answer_d
ࣗݾհ • SIer • Πϯϑϥ͞Μ αʔόߏஙϚϯ • ʮAnsible͍ͬͯ͜͏Ͷʔʯͳ৬͚ͩͲීٴඍົ
͋ΔͷͰ͖͝ͱ
͋ΜͰ͌ʔ͘ΜAnsible Ͱ͖ΔΜͩΑͶʁ ͪΐͬͱͬͯΑʂ ͔͜͠·Γ
։ൃڥʁ ͳ͍ΑɺඞཁͩͬͨΒԿ͔ߟ͑ͯ
ΦϯϓϨҊ݅͋Δ͋Δ(͔ʁ)
ຊ൪ ։ൃ ౦ ։ൃڥ(·ͩ)ͳ͍
ຊ൪ ։ൃ ౦ (Ծʹ͋ͬͯ)ߏҧ͏ 2ϊʔυΫϥελ → γϯάϧ ౦ܥ →
౦ͷΈ ػೳ͝ͱʹαʔόׂ → ूͯ͠1 IPશવҧ͏
ϓϨΠϒοΫͷ࣭֬อ Ͳ͏͠Α͏ɾɾɾ
Ͱ͖Ε ຊ൪Ͱྲྀ͢ϓϨΠϒοΫΛ ͦͷ··ྲྀͯ͠ಈ࡞֬ೝ͍ͨ͠
DockerͰͰ͖ΔΜ͡ΌͶʁ
Γ·ͨ͠
ͬͨ͜ͱ • CentOSͷίϯςφͨ͘͞Μ → ຊ൪ڥͲ͖ ɾ 1ίϯςφ = 1αʔό(ͷΑ͏ͳԿ͔) •
docker-composeͰ·ͱΊ্ͯ͛Լ͛ • Ͱ͖Δ͚ͩຊ൪ڥΛ࠶ݱ ɾ ݻఆIP ɾ hostsͰ໊લղܾ
͍ํΠϝʔδ
$ docker-compose up up! ͚ͩʂ ຊ൪Ͳ͖ίϯςφୡ
࡞ͬͨͭ
Dockerfile
FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf
\ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ>' | chpasswd --encrypted \ && true CMD [“/sbin/init"]
FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf
\ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] CentOSΠϝʔδ͕ ϕʔεͰ
FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf
\ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] Ansibleͱ͔ೖΕͯ ※ ࣾڥͷͨΊϓϩΩγܦ༝
FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf
\ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] sshΛຊ൪ͱಉ͡ઃ ఆʹͯ͠
FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf
\ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] ຊ൪ͱಉ͡Ϣʔβ ࡞ͬͯ
FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf
\ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] initϓϩηεΛ࣮ߦ
docker-compose.yml
version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:
internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254
target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged:
true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254 version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image: internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true Ansibleϗετ λʔήοτϊʔυୡ
version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:
internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true ͖ͬ͞ͷ Dockerfile target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254
version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:
internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254 ݻఆIPׂΓͯ
version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:
internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true hosts target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254
Α͔ͬͨ͜ͱ • ࡞Δͷ؆୯ͩͬͨͷͰ(ແৼΓʹ) ͑Εͨ • Docker͑͋͞ΕͲ͜Ͱڥ্ཱ͕͕ͪΔ • ىಈఀࢭVMΑΓૣ͍ • down→up͚ͩͰॳظঢ়ଶʹͳΔͷΊͬͪΌศར
·ͱΊ
• docker-composeͰϓϨΠϒοΫݕূ͢Δڥ࡞ͬͨ • ؆୯ʹͰ͖ͯ͘͢͝ศརͩͬͨ • Ͱࣄલʹ։ൃڥͬͱߟ͑ͯʂʂʂʂʂ(ഭਅ)
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ