12-Day5-1-include_tasksAndimport_tasks
Day 5: Lab Exercise - Using Include and Import for Task and Play Segregation
Lab 1.1: Using include_tasks for Dynamic Task Inclusion
include_tasks for Dynamic Task Inclusion- name: Install Apache yum: name: httpd state: present - name: Start and enable Apache service: name: httpd state: started enabled: true- name: Install Nginx yum: name: nginx state: present - name: Start and enable Nginx service: name: nginx state: started enabled: true
- name: Include Tasks Dynamically hosts: all vars: web_server: apache tasks: - name: Dynamically include tasks based on web_server variable include_tasks: "tasks/install_{{ web_server }}.yaml"
ansible-playbook ~/day5/include_tasks_playbook.yaml
Lab 1.2: Using import_tasks for Static Task Inclusion
import_tasks for Static Task InclusionLab 1.3: Using import_playbook for Playbook Segregation
import_playbook for Playbook SegregationOptional Lab 1.4: Dynamic Web and Database Role Assignment
Key Learning Points:
Last updated