francsw / EX407-Ansible-Automation

Red Hat Certified Specialist in Ansible Automation (EX407) Preparation Course
0 stars 0 forks source link

LAB: Ansible Playbooks - Error Handling #6

Open francsw opened 3 years ago

francsw commented 3 years ago
francsw commented 3 years ago
---
- hosts: localhost
  gather_facts: no
  become: no

  tasks:
  - name: Download tthe file from node1
    block:
      - get_url:
          url: http://node1/transaction_list
          dest: ./transaction_list
      - debug:
          msg: "File downloaded"
      - name: Replace BLANKFILE
        replace:
          path: ./transaction_list
          regexp: '#BLANKLINE'
          replace: '\n'
    rescue:
      - name: It fialed
        debug:
          msg: "node1 seems to be down. Try again later"
    always:
      - debug:
          msg: "Attempt Completed"