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

Managing Modern Infrastructure with Ansible

Managing Modern Infrastructure with Ansible

Joe Ferguson

October 24, 2019

More Decks by Joe Ferguson

Other Decks in Programming


  1. Managing Modern Infrastructure with Ansible Joe Ferguson https://github.com/svpernova09/ModernInfrastructureWithAnsible

  2. Who Am I? Joe Ferguson PHP Developer Senior Full Stack

    Dev @ Preteckt Open Source Geek ⚽,, and fan Twitter: @JoePFerguson
  3. Ansible for DevOps https://leanpub.com/ansible-for-devops

  4. None
  5. pip install ansible

  6. Ansible Concepts Modules Standalone work units to perform a task

    Inventory Configuration Declaration of target systems to perform tasks upon Playbooks Complete set of roles / list of actions to take
  7. Command Module

  8. Command Module

  9. Command Module

  10. Create Ansible Playbook

  11. Running Our Ansible Playbook

  12. Ansible Variable Precedence http://docs.ansible.com/ansible/playbooks_variables.html

  13. Ansible Variable Precedence • command line values (eg “-u user”)

    • role defaults • inventory file or script group vars • inventory group_vars/all • playbook group_vars/all • inventory group_vars/* • playbook group_vars/* • inventory file or script host vars
  14. Reusing Playbooks from others

  15. Ansible Galaxy Authors

  16. Adding geerlingguy.php

  17. Overriding Variables

  18. Overriding Variables

  19. Adding ansible-role-php

  20. Adding ansible-role-php

  21. Running ansible-role-php

  22. Production Inventory

  23. Staging Inventory

  24. Dev Inventory

  25. ansible_playbook -i prod.ini <playbook> ansible_playbook -i staging.ini <playbook> ansible_playbook -i

    dev.ini <playbook>
  26. Ansible can deploy your code

  27. General Ansible Advice Use environment based playbooks & inventory files

    for clear separation & to easily handle one off differences Use Python or some other environment variable system for managing your secrets! Couple variables to the most focused point, then raise their scope as you need
  28. Ansible Tower https://www.ansible.com/products/tower

  29. Ansible Tower https://www.ansible.com/products/tower/pricing

  30. AWX - Open Source Tower

  31. AWX - Open Source Tower

  32. Python for PHP Devs Python PHP Composer Packagist composer.json FPM

    ??? composer.lock Pip PyPi & Others requirements.txt WSGI VirtualEnv LOL lock files
  33. Virtual Environments

  34. Install Dependencies

  35. Install Dependencies

  36. Freeze Dependencies

  37. Our Virtual Env

  38. Building a Deploy Playbook http://vcdt.joeferguson.me/

  39. Playbook File

  40. deploy-vcdt-app Role

  41. deploy-vcdt-app Role

  42. Using Jinja2 Templates

  43. Update the Repository

  44. Composer Install

  45. Application Setup

  46. Job’s Done!

  47. Break Up Large YAML

  48. System Maintenance

  49. System Maintenance

  50. Install & Configure Certbot

  51. Create SSL & Cron

  52. Combine SSL For HAProxy

  53. Delayed Service Restarting

  54. Renewal Post Hook Script

  55. Renewal Post Hook Script

  56. Install Docker

  57. Install Docker

  58. Add Users

  59. Looping over Arrays (Hashes)

  60. Directory Layout

  61. Directory Layout

  62. Directory Layout

  63. Keep Your Secrets Secret!

  64. Rolling Updates: Serial

  65. Maximum Failure

  66. Joe Ferguson Twitter: @JoePFerguson Email: [email protected] Contact Info: Thanks!