1

is there any option for the replay the play in the playbook? I want to write ansible playbook like below. I want to run play2 if any error in the play1_result and after running play1 if play2 is a success

tasks:
  - name: play1
    ...
    register: play1_result

  - name: play2
    ...
    when: 'FAILED' in play1.stderr
1

"to run play2 if any error in the play1_result"

an option would be to use block

- block:
    - name: play1
      ...
  rescue:
    - name: play2
      ...

to replay the play1 after the rescue section ran the play2

  rescue:
    - name: play2
      ...
    - name: play1
      ...
  • Hi Vladimir, thanks for the answer I want to replay the play1 after the rescue section ran the play2. Probably, this rescue did not provide my condition. – arifisik Jan 14 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.