---
- hosts: web
  name: This is a play within a playbook
  become: yes

  vars:
    httpd_packages:
      - httpd
      - mod_wsgi

  tasks:
    - name: install packages
      yum:
        name: "{{ item }}"
        state: present
      with_items:
        - libselinux-python
        - firewalld

    - name: stop firewalld
      service:
        name: firewalld
        state: stopped

    - name: Install httpd packages
      yum:
        name: "{{ item }}"
        state: present
      with_items: "{{ httpd_packages }}"

    - name: copy index.html
      copy:
        src: files/index.html
        dest: /var/www/html/
      notify: restart apache

  handlers:
    - name: restart apache
      service:
        name: httpd
        state: restarted
        enabled: yes

- hosts: web
  name: This is a play within a playbook
  become: yes

  vars:
    httpd_packages:
      - httpd
      - mod_wsgi
      - libselinux-python
      - firewalld

  tasks:
    - name: install packages
      yum:
        name: "{{ item }}"
        state: present
      with_items: "{{ httpd_packages }}"

    - name: stop firewalld
      service:
        name: firewalld
        state: stopped

    - name: copy index.html
      copy:
        src: files/index.html
        dest: /var/www/html/
      notify: restart apache

  handlers:
    - name: restart apache
      service:
        name: httpd
        state: restarted
        enabled: yes

Make playbook example more efficient
Make playbook example more efficient
