Skip to Content
Implementing Modern DevOps
book

Implementing Modern DevOps

by David Gonzalez, Danny Varghese
October 2017
Intermediate to advanced
326 pages
7h 20m
English
Packt Publishing
Content preview from Implementing Modern DevOps

Ansible templates

Templates are another powerful tool from Ansible. They allow us to render configuration files, application properties, and anything that can be stored in a human readable file.

Templates rely heavily on variables and a template engine called Jinja2 , which is used by Ansible to render the templates. First, we are going to install ngnix on our server with a simple playbook:

---- hosts: all user: root tasks: - name: Update sources apt: update_cache: yes - name: Upgrade all packages apt: upgrade: dist - name: Install nginx apt: name: nginx state: present
As you can see, it is very simple:
  • Update the apt cache
  • Upgrade the system
  • Install nginx

Now, just run the preceding playbook using the VM created earlier:

ansible-playbook ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical DevOps

Practical DevOps

joakim verona
Hands-On Security in DevOps

Hands-On Security in DevOps

Tony Hsiang-Chih Hsu
SRE with Java Microservices

SRE with Java Microservices

Jonathan Schneider

Publisher Resources

ISBN: 9781786466877Supplemental Content