hii i have a playbook there my target host is amazon2 vm
---
- hosts: target1
become: true
tasks:
- name: Install and configure httpd web server
block:
- yum:
name: httpd
state: present
- service:
name: httpd
state: started
when: ansible_facts['distribution'] == 'CentOS'
rescue:
- debug:
msg: "Playbook has failed for {{ inventory_hostname }} node"
when i run this i got this logs
PLAY [target1] *******************************************************************************************
TASK [Gathering Facts] ***********************************************************************************[WARNING]: Platform linux on host 13.234.119.169 is using the discovered Python interpreter at
/usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more
information.
ok: [13.234.119.169]
TASK [yum] ***********************************************************************************************skipping: [13.234.119.169]
TASK [service] *******************************************************************************************skipping: [13.234.119.169]
PLAY RECAP ***********************************************************************************************13.234.119.169 : ok=1 changed=0 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
there when: ansible_facts[‘distribution’] == ‘CentOS’ should be
when: ansible_facts[‘distribution’] == ‘Amazon’ then i will run but when centos is there it is a error then i should run rescue but it is not running