Ansible Basics - Revisiting Ansible lab issue

I was completing the Ansible Basics course and doing the Revisiting Ansible lab. For the question 9 (screenshot attached) I am facing the issue that the files the playbook is supposed to create are getting cleaned up almost immediately, causing the checks to fail. There are two plays that create two different files on two different nodes.

  • When play 1 is running if I click on Check, the check for play 1 file succeeds, however the check for play 2 file fails (play hasn’t started yet)
  • When play 2 is running if I click on Check, the check for play 2 file succeeds, however the check for play 1 file fails (file has been cleaned up)
  • When I click on check after some time of playbook execution, both checks fail (files are not available on either host anymore)

What’s in your perm.yml file for this question? This is mine; it checks out in the grader:

[bob@student-node playbooks]$ cat perm.yml 
---
- hosts: node01
  become: true
  tasks:
    - name: Creating blog.txt file
      file:
        path: /opt/news/blog.txt
        state: touch
        group: sam

- hosts: node02
  become: true
  tasks:
    - name: Creating story.txt file
      file:
        path: /opt/news/story.txt
        state: touch
        owner: sam

Hey @rob_kodekloud thanks for your reply.

The initial perm.yml file that I wrote used when modules to execute based on the host where it is running, so I initially thought that might be the problem. But then I changed to this and I was still facing the issue. So I copied the file provided in the solution section and it still persisted.

I believe the issue was not with the file, but with the cleanup jobs running in the background for the VMs resetting the hosts node01 and node02 erratically. As I mentioned, if I time it right, I do get the individual checks to pass. Even if the check passes once, if I click on Check again, it ends up failing.

SSH into the node and checking the directory I can confirm the file gets removed (assuming removed because the check does initially pass)