Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-5204

RH294-232: 6.4 Including and Imporing Files GE

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Done
    • Icon: Minor Minor
    • AU294 - RHAAP2.X NEXT
    • RH294 - RHEL9.0-en-2-20221117
    • RH294
    • None
    • 6
    • en-US (English)

      URL:
      Reporter RHNID:
      Section: -
      Language: en-US (English)||||||||
      Workaround:

      Description: Please consider using FQCN for the import_tasks, include_tasks, import_playbook modules to match the style of the rest of the course book.

      Also, in my experience students always have questions about the import_tasks vs. include_tasks module behavior. Unfortunately, this exercise uses them in a way that is completely interchangeable. I think the most noteworthy difference is how a when keyword applies to these modules. It would be very easy to add a simple test to these tasks in this play, like checking the linux distro fact, just for students to see how the test gets repeated for each of the 3 firewall tasks.

      - name: Include the environment task file and set the variables
            ansible.builtin.include_tasks:
              file: tasks/environment.yml
            vars:
              package: httpd
              service: httpd
            when: ansible_facts['distribution'] == "RedHat"
      
          - name: Import the firewall task file and set the variables
            ansible.builtin.import_tasks:
              file: tasks/firewall.yml
            vars:
              firewall_pkg: firewalld
              firewall_svc: firewalld
              rule:
                - http
                - https
            when: ansible_facts['distribution'] == "RedHat"
      

      Run it first with RedHat, then have students change it to Fedora and see the tests fail.

              glsbugs-automation@redhat.com PTL - Ansible Team
              zoltanmolnar Zoltan Molnar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: