DevOps Classroom Series – 25/Dec/2020

Ansible Variables

  • So if we try install apache on centos & ubuntu our playbook will appear as
---
- hosts: ubuntu
  become: yes
  tasks:
    - name: install apache
      package:
        name: apache2
        state: present
- hosts: centos
  become: yes
  tasks:
    - name: install apache in centos
      package:
        name: httpd
        state: present
  • So lets use the variable concept of ansible Refer Here
  • Variables in the ansible can be defined in
    • inventory
    • folders around inventory
    • playbook
    • commandline
  • For today’s session lets focus on variables in inventory
  • Lets create a simple playbook Refer Here
  • IN ansible to run the same task with different values, lets use a ansible loop Refer Here
  • Exercise: Now try Writing an ansible playbook for install tomcat8 on ubuntu and centos

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin