Zero to Hero [en]

Zero to Hero [en]

Fully Automated Web App Setups (using Ansible and Phing) - @bephpug 2014-11-04

6e15b56fcb16fae0747810827be8ce8f?s=128

Christoph Lühr

November 04, 2014
Tweet

Transcript

  1. Christoph Lühr @chluehr / bephpug 2014-11 Case study / Demo

    Zero to Hero "Fully Automated Web App Setups"
  2. "Automated server install process == administrator bliss"

  3. "Automated server install process == developer bliss"

  4. None
  5. basilicom

  6. basilicom SIN CE 2000

  7. Image source: http://www.flickr.com/photos/robby_van_moor/5702589201/ CC BY-ND 2.0

  8. None
  9. None
  10. (#) Internet

  11. (#80) PPY

  12. None
  13. ?

  14. Project

  15. INSTALL.TXT

  16. INSTALL.md

  17. ➊ ➋ ➌ ➍ ➎ ➏

  18. None
  19. FAQ

  20. PHP Code

  21. PHP-Code DB-SQL

  22. Code DB FS

  23. Code DB FS ...

  24. None
  25. None
  26. None
  27. Code REQUIREMENTS

  28. Code OS + Server + Tools

  29. Code OS + Server + Tools ... Settings ... Versions

    ...
  30. ?

  31. REQUIRE.TXT

  32. ➊ ➋ ➌ ➍ ➎ ➏

  33. None
  34. FAQ

  35. FFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFUUUU UUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUU UUUUUUUUUUUUUUUUU UU.......

  36. Code OS

  37. Code OS Hardware

  38. Code OS VM

  39. Services Code OS VM

  40. DNS / SMTP / ... Code OS VM

  41. ?

  42. None
  43. FAQ ➊ ➋ ➌ ➍ ➎ ➏

  44. CODE

  45. Code >

  46. API >

  47. $cli >

  48. OneGet

  49. Services Code OS Hardware

  50. VM

  51. OS + Tools

  52. OS + Tools

  53. OS + Tools

  54. Project

  55. Services Google Cloud DNS

  56. None
  57. Kassandra

  58. "META API"

  59. REST ... LOG APIs ACL

  60. Demo

  61. Demo

  62. $ git clone git@git.host.... $ phing setup

  63. $ git clone git@git.host.... $ phing serversetup

  64. $ phing serversetup Buildfile:build.xml project > serversetup: Create JiffyBox automatically

    via API (Y,N) [Y]? Y Enter your Kassandra-API token: 5e#XhF8tHGr9^dWffq2pDT5Q [echo] Generating root password [echo] Root password is: 2baf4503a861448ca109 [echo] Creating JiffyBox via Kassandra API (ID/IP) - please wait ... [echo] JiffyBox is created, ID: 105754 IP: 134.119.20.131 [echo] Retrieving project repository url and name via git [exec] git@git.githost.de:basilicom-de/bas-test.git [echo] Updating ansible inventory-production file [echo] Updating local ssh known_hosts file
  65. [echo] Setting up remote host os/software via ansible, this will

    take a couple of minutes, please wait ... [exec] PLAY [Install LAMP Stack with PHP 5.5 and MySQL] [exec] TASK: [upgrade | Running apt-get update] [exec] TASK: [upgrade | Running apt-get upgrade] [exec] TASK: [common | Common software] [exec] changed: [134.119.20.131] => (item=python-software-properties, build-essential,curl,screen,vim,ntp,jpegoptim, pngcrush,git-core,ufw)
  66. [exec] TASK: [common | Set default locale] [exec] TASK: [ffmpeg

    | Download static FFMPEG binaries] [exec] TASK: [ffmpeg | Extract static FFMPEG binaries] [exec] TASK: [apache | Install Apache] [exec] TASK: [apache | Enable Apache2 rewrite module] ... [exec] TASK: [apache | Disable server signature] [exec] TASK: [apache | Disable server tokens] [exec] TASK: [apache | Set max request workers to 60] [exec] TASK: [pagespeed | Download mod_pagespeed] [exec] TASK: [pagespeed | Install mod_pagespeed] [exec] TASK: [mysql | Install MySQL server] [exec] TASK: [memcached | Memcached] [exec] TASK: [mongodb | MongoDB]
  67. [exec] TASK: [php | Install PHP5] [exec] changed: [134.119.20.131] =>

    (item=php5-common,php5-mysqlnd, php5-xmlrpc,php5-mcrypt,php5-curl,php5-gd,php5-cli, php-pear,php5-dev,php5-imap,php5-imagick,php5-memcache, php5-mongo,libapache2-mod-php5) [exec] TASK: [php | Enable PHP5 opcode cache] [exec] TASK: [php | Enable PHP5 mcrypt] [exec] TASK: [php | Raise PHP memory Limit for Apache] [exec] TASK: [php | Allow short open tags for Apache PHP] [exec] TASK: [php | 8MB max upload size] [exec] TASK: [composer | Add Composer PPA] [exec] TASK: [composer | Install Composer]
  68. [exec] TASK: [shell-access | Set the hostname] [exec] TASK: [shell-access

    | Set IP in hosts file for hostname] [exec] TASK: [shell-access | SSH Key-Pair for www-data] [exec] TASK: [shell-access | Create authorized_keys file] [exec] TASK: [shell-access | Create ssh config file] [exec] NOTIFIED: [apache | restart apache2] [exec] NOTIFIED: [beanstalkd | restart beanstalkd] [exec] [exec] PLAY RECAP ******************************************************************** [exec] 134.119.20.131 ok=59 changed=53 unreachable=0 failed=0
  69. [echo] Retrieving remote ssh-key for deployment [echo] Adding deployment ssh-key

    to bitbucket repository via Kassandra API [echo] Installing project on remote host via ansible/phing, this will take a couple of minutes, please wait ... [exec] TASK: [clone-git | clone Project]
  70. [exec] TASK: [pimcore | Pimcore setup] [exec] ok: [134.119.20.131] =>

    { [exec] "pimcoresetup.stdout_lines": [ [exec] "project > setup:", [exec] " [echo] PHING PROJECT SETUP - installing on: local " [exec] "project > dbcreate:", [exec] " [echo] Creating Database / Access - [dbcreate]", [exec] "project > pimcoremerge:", [exec] " [echo] Download and unpack pimcore distribution ", [exec] "project > pimcoreinstall:", [exec] " [echo] Installing Pimcore - [pimcoreinstall]", [exec] "project > configcreate:", [exec] " [echo] Creating set of configs in var/build", [exec] "project > apacheconfig:", [exec] " [echo] Configure Apache - [apacheconfig]", [exec] " [exec] Enabling site bas_pimtest.", [exec] " [exec] service apache2 reload", [exec] "project > installcron:", [exec] " [echo] Installing pimcore maintenance cron job", [exec] "BUILD FINISHED", [exec] ] [exec] }
  71. [echo] Creating DNS Record via Kassandra API: A bas-test.appr.info 134.119.20.131

    TTL 300 [echo] Finally rebooting remote host [echo] ---------------------------------------------------------- [echo] PHING SERVER PROJECT SETUP - DONE [echo] ========================================================== BUILD FINISHED Total time: 7 minutes 2.14 seconds
  72. Fully Automated Server Setup BENEFITS

  73. ➊ Fast

  74. ➋ Repeatable

  75. ➌ Documented

  76. ➍ Re-usable

  77. "App setup should be defined as code and needs to

    be alive."
  78. Image source: http://www.flickr.com/photos/rietje/76566707/ CC BY 2.0

  79. Unicode Character 'HAPPY PERSON RAISING ONE HAND' (U+1F64B)

  80. Thanks! Questions? Christoph Lühr luehr@r-pentomino.de christoph.luehr@basilicom.de @chluehr Slides license Attribution-NonCommercial-ShareAlike

    3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/
  81. • Phing http://www.phing.info/ • Ansible http://www.ansible.com/ • Sample Vagrant, Phing

    & Ansible project setup http://bit.ly/basilicom-pimcore-setup-blog