I have below pseudo code to implement in ansible.
changed = true
if (changed)
{
   print("The first block executes")
}
else
{
  print("The second block executes.")
  changed = false
}
Now I need to convert above logic into ansible playbook , so that when I run the playbook first time , it prints the first block and all subsequent calls must print second block. I tried below but it didn't worked.
hosts: localhost
become: true
vars:
  changed: "true"
tasks:
  - name: First block
    debug:
      msg: "The first block is printed"
    when: changed == "true"
  - name: Second block
    debug:
      msg: "The second block is printed"
  - set_fact:
      changed: "false"
Can someone guide me if this use case can be implemented in ansible? The main ask is that can a playbook be designed such that it changes its behaviour after the first run. If I run the playbook first time it should print the first block but in all subsequent execution of that playbook it should only execute second block message only.
 
    