Single Playbook for previous exercise:

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Build many sub-playbooks and aggregate them via include statements.
- include: playbook-1.yml
- include: playbook-2.yml

Note - 
include is deprecated. docs.ansible.com/ansible/latest/playbooks_reuse.html import_playbook: foo is the right way to go

For newer versions of Ansilbe, you can build many sub-playbooks and aggregate them via import_playbook statements:
---
- import_playbook: A-systemd-networkd.yml
- import_playbook: B-fail2ban-ssh.yml
- import_playbook: C-enable-watchdog.yml
playbook1.yaml:group                                 ---create group
- name: Deploying group
  hosts: web

  tasks:
  - name: create group
    group:
      name: deploy
      state: present
  
playbook-2:httpd                                  -----install http package
- name: Start the first play
  hosts: web
  
  tasks:
  - name: Install the latest version of Apache
    yum:
      name: httpd
      state: latest
  - name: Copy file with owner and permissions
    copy:
      src: index.html
      dest: /var/www/html/index.html
  - name: Start service httpd, if not started
    service:
      name: httpd
      state: started


playbook-3:mysql                                   ------install mysql package
- name: Start the first play
      
  hosts: db
  
tasks:
  - name: Install the latest version of Apache
    yum:
      name: mysql
      state: latest
  - name: Start service httpd, if not started
    service:
      name: mysqld
      state: started

playbook4:installgit                              ------install git
- name: Update web servers
  hosts: web
  vars:
    myname: gitinstalled
    age: "18"
    packagename: github
    servicename: github
  vars_files:
    - "vars.yaml"
  vars_prompt:
    - name: "version"
      prompt: "Which version Do you want to install?"
      private: no

playbook-5:gropinsidegroup                             ----create group in another group with /bin/bash
- name: Deploying user
  hosts: web

  tasks:
  - name: create user
    user:
      name: deploy-user

      shell:/bin/bash
      group: deploy

playbook-6:httpd service                                 ------enable http service
- name: Starting the service
  hosts: webservers

  tasks:
  - name: start service
    service:
      name: httpd

      state: started

playbook-7:createfile                                         ----create dummy index.html file
- name: Initiating File Creation
  hosts: webservers

  tasks:
  - name: creating a file
    copy:
      src: index.html

      dest: index1.html

playbook-8:copyfile                                          ------copy second.html 
- name: Copying File
  hosts: webservers

  tasks:
  - name: copy a file
    copy:
      src: seecond.html

      dest: /var/www/html/second.html