Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ansible: infrastructure automation for everyone

208 views

Published on

Ansible will help you to become sysadmin in no time ;)

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Ansible: infrastructure automation for everyone

  1. 1. Ansible INFRASTRUCTURE AUTOMATION FOR EVERYONE 2018-05-03 VilniusPHP 0x42 Žilvinas Kuusas
  2. 2. “People often ask me how does Ansible compete with other configuration management tools? We don’t, we compete with Bash.” -- Greg DeKoenigsberg, CfgMgmtCamp 2016, Gent (BE), 2016-02-02
  3. 3. Ansible Using Ansible, we can reduce the service interruption time, test the infrastructure, reduce the risk of accidents, and seamless integration the development, testing and production environment.
  4. 4. Ansible ● No agents to install on remote systems (SSH + python) ● Code in YAML ● Appropriate for managing small-medium setups ● Acquired by RedHat in October 2015.
  5. 5. Ansible ● Inventory ● Ad-Hoc commands ● Playbooks ● Modules
  6. 6. Ansible: Inventory ● Hosts and Groups ● Host/Group Variables ● Groups of Groups, and Group Variables
  7. 7. Ansible: Hosts and Groups all: hosts: mail.example.com: children: webservers: hosts: foo.example.com: bar.example.com:
  8. 8. Ansible: Ad-Hoc commands ● Short (temporality) command, like the normal (classic) command line mode, operate it with one line at a time # ansible <host-pattern> -m [module_name] [-a args] [options]
  9. 9. Ansible: PlayBooks ● Tasks ● Variables ● Templates ● Handlers ● Roles
  10. 10. Ansible: PlayBooks - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: name: httpd state: latest
  11. 11. Ansible: PlayBooks - Roles structure site.yml webservers.yml fooservers.yml roles/ common/ tasks/ handlers/ files/ templates/ vars/
  12. 12. Ansible: PlayBooks - Roles usage - hosts: webservers roles: - common - webservers If roles/x/tasks/main.yml exists, tasks listed therein will be added to the play. If roles/x/handlers/main.yml exists, handlers listed therein will be added to the play.
  13. 13. Ansible: running playbooks $ ansible-playbook my-playbook.yml -i inventory -e extra_variable=value
  14. 14. Ansible: Templates - Jinja2 {{ some_variable }} {{ some_variable | to_json }} ...
  15. 15. Ansible: Modules ● Core modules are included with Ansible and are written and maintained by the Ansible development team. Core modules are the most important modules and are used for common administration tasks. ● Extras modules are currently included with Ansible but may be promoted to core or shipped separately in the future. They are generally not maintained by the Ansible team but by the community. ● Custom modules are modules developed by end users
  16. 16. Ansible: Modules - name: example copying file with owner and permissions copy: src: /srv/myfiles/foo.conf dest: /etc/foo.conf owner: foo group: foo mode: 0644
  17. 17. Ansible: Modules # enables the Apache2 module "wsgi" - apache2_module: state: present name: wsgi # disables the Apache2 module "wsgi" - apache2_module: state: absent name: wsgi
  18. 18. Ansible Tower
  19. 19. ● Ansible Tower is a web-based solution that makes Ansible even more easy to use for IT teams of all kinds. It’s designed to be the hub for all of your automation tasks. Ansible: Tower
  20. 20. Ansible: Tower ● Tower allows you to control access to who can access what, even allowing sharing of SSH credentials without someone being able to transfer those credentials. Inventory can be graphically managed or synced with a wide variety of cloud sources. It logs all of your jobs, integrates well with LDAP, and has an amazing browsable REST API. Command line tools are available for easy integration with Jenkins as well.
  21. 21. Ansible: Galaxy ● Ansible roles provided by community
  22. 22. Ansible benefits ● Setup server without knowledge ● Reduce risk of human error ● Respond and scale in pace with demand ● Infrastructure as the code
  23. 23. Ansible cons ● Slow with larger infrastructures (20+ servers)
  24. 24. DEMO and examples
  25. 25. Questions?
  26. 26. Ačiū!

×