Upgrade to Pro — share decks privately, control downloads, hide ads and more …

applibotのDevOpsを支える terraform/packer

September 11, 2018

applibotのDevOpsを支える terraform/packer

2018/09/11 DevOpsを支える今話題のHashiCorpツール群について

September 11, 2018
Tweet

More Decks by 遊

Other Decks in Technology

Transcript

  1. ೋ ࣇ ͷ ෕  ͤ ͍ ΂ ͭ ɿ

    ͓ ͱ ͜  Ϩ ϕ ϧ ɿ    ) 1          . 1       ࣾ ձ ਓ ྺ         d        ɹ % $ Ͱ ؂ ࢹ Φϖ Ϩ ʔ λ ʔ         d        ɹ ג ࣜ ձ ࣾ ɹ ɹ ɹ       ɿ 4 : 4 5 & .  0 1 & 3 "50 3         d  / 0 8 ɹ ɹ  ג ࣜ ձ ࣾ " 1 1 - * # 05 ɿ 4 : 4 5 & .  0 1 & 3 "50 3 ͳ · ͑ ɹ ɹ ɿ ੢ ଜ ɹ ༡  ͭ ͍ ͬ ͨ ʔ ɿ !HBDIBSJPO HVNJ ࣗ ݾ ঺ հ
  2. Packer • ༻్ • AMI / GCP Image / Container

    Imageͷ࡞੒ • ansibleͱซ༻ͯ͠࢖༻ • ϝϦοτ • Πϝʔδ࡞੒ͷྲྀΕΛςϯϓϨʔτԽ
  3. after $ p a c k e r b u

    i l d p a c k e r . j s o n ʊਓਓਓਓਓਓਓਓਓʊ ʼɹίϚϯυҰൃʂɹʻ ʉ:?:?:?:?:?:?ʉ
  4. JOB

  5. ෛՙࢼݧͷ৔߹ͷ໾ׂ ෛ ՙ ࢼ ݧ Λ ͔ ͚Δ ਓ 

     γ φ Ϧ Φ ࡞ ੒   ࢼ ݧ ࣮ ߦ   ݁ Ռ · ͱ Ί ෛ ՙ ࢼ ݧ ؀ ڥ Λ ࡞ Δ ਓ   ؀ ڥ ࡞ ੒   ߏ ੒ ม ߋ   Ϩ Ϗϡ ʔ αʔόΤϯδχΞ γεΦϖ
  6. Α͋͘Δޫܠ ৽ Πϕ ϯ τ ։ ൃ ͠ · ͠

    ͨ ʂ  ෛ ՙ ࢼ ݧ ΍ Γ ͨ ͍Ͱ ͢ ʂ  ͍ ͭ · Ͱ ʹ ༻ ҙ Ͱ ͖ · ͢ ͔ ʂ ʁ ͏ ʔ ʔ ʔ ʔ Μ ɻ ࠓ ख ͕ ۭ ͔ ͳ ͍ ͔ Β ʜ   ೔ ͙ Β ͍Ͱ ʜ ͦ͘ ͓ ͦ ʂ  ʢ ྃ ղ Ͱ ͢ ʂ  ΑΖ ͠ ͘ ͓ ئ ͍ ͠ · ͢ ʂ ʣ
  7. ༻ҙ͢Δ΋ͷ ΠϯϑϥपΓ w ࠷ऴతʹɺຊ൪ಉ౳ͷ؀ڥ w ࢼݧͷλΠϛϯάͰ࡞੒ w ෛՙΛ͔͚Δαʔό w +.FUFSΛ࢖༻

    &$ ɻωοτϫʔΫ͸ผɻΞΧ΢ϯτ෼͚͍ͯΔ w ֤छϞχλϦϯά w HSBGBOBQSPNFUIFVTLJCBOB FMBTUJDTFBSDI w ͜͜͸ࠓճؔ܎ͳ͠
  8. ॖখ༻ ########################## ## Aurora InstanceClass ## ########################## rds_master_class = “db.r3.2xlarge"

    ################# ## Autoscaling ## ################# desired_capacity = “10” ֦ு༻ ########################## ## Aurora InstanceClass ## ########################## rds_master_class = “db.t2.medium” ################# ## Autoscaling ## ################# desired_capacity = “0” ֦ுॖখ͸WBSTϑΝΠϧͷ
 ੾Γସ͑ͰରԠ
  9. # ద༻͢ΔvarsΛηοτ vars_file=vars_file/${OPTARG}_value.tfvars # tfstateόοΫΞοϓ if [ ${option} == "apply"

    ]; then terraform state pull > backup/terraform.tfstate_backup_`date +"%Y-%m-%d-%H-%M- %S"` fi # terraform࣮ߦ (plan or apply) terraform ${tf_option} -var-file=${vars_file} ࣮ߦ༻εΫϦϓτ
  10. after hoge hoge hoge w εέʔϧͷݖݶΛΞϓϦνʔϜ΁Ҡৡ w Ͳ͏͍͏؀ڥͰࢼݧ͍ͯ͠Δ͔ͷ
 ֬ೝ΋༰қ w

    ϘτϧωοΫՕॴͷมߋ΋
 WBSTͷ஋Λ͍͡Δ͚ͩͰมߋͰ͖Δ εϐʔυײͷ͋ΔରԠΛ
 ߦ͏͜ͱ͕Ͱ͖Δ
  11. ৽نαʔϏεͷ؀ڥߏஙͷྲྀΕ ͦ Ζ ͦ Ζ α ʔ ό ͱ ૄ

    ௨ ͯ͠ ֬ ೝ ͠ ͨ ͍  ͍ ͭ · Ͱ ʹ ༻ ҙ Ͱ ͖ · ͢ ͔ ʂ ʁ Ξ Χ ΢ ϯ τ ͔ Β ͷ ༻ ҙ ͩ ͔ Β ɺ  ͋ Ε ͍ Εͯ ͜ Ε ͍ Εͯ ͋ ͹ ͹ ͹ ʜ   ೔ ͙ Β ͍Ͱ ʜ ͦ͘ ͓ ͦ ʂ  ʢ ྃ ղ Ͱ ͢ ʂ  ΑΖ ͠ ͘ ͓ ئ ͍ ͠ · ͢ ʂ ʣ
  12. BQQMJCPUͷUFSSBGPSN  ϑΥϧμߏ੒ • 00_base • ΞΧ΢ϯτ࡞੒࣌ʹ࡞੒͢ΔαʔϏε܈ • CloudTrail /

    Route53 / keypair / S3(awsؔ࿈ͷϩά༻) / IAMUser • 01_common / 02_dev / 03_stg / 04_prd • ֤؀ڥ໊ɻιʔτ༻ʹ൪߸ৼ͍ͬͯΔ • workspace͸ఘΊ·ͨ͠ • 99_modules • ֤؀ڥ͕ڞ௨Ͱ࢖༻͢Δઃఆ • ྫ: VPC Network