skipping: no hosts matched - Multiple play

69 views
Skip to first unread message

kumare...@gmail.com

unread,
Apr 3, 2021, 5:30:02 AM4/3/21
to AWX Project
Hi Experts,

I am using below playbook in awx tower getting "skipping: no hosts matched" in second play.The variable are passed from survey.

Variables from tower survey:

source_host
destination_host
file1
file2

Playbook:
---
- hosts: "{{ source_host }}"
  become: true
  ignore_errors: yes
  tasks:
    - name: Create file
      shell: touch /tmp/"{{file1}}"

- hosts: "{{ destination_host }}"
  become: true
  ignore_errors: yes
  tasks:
    - name: Create the file
      shell: touch /tmp/"{{file2}}"


Error:

PLAY [node1] *************************************************************

TASK [Gathering Facts] *********************************************************

ok: [`node1]

TASK [Create the file] ****************************************************

changed: [node1]

PLAY [node2] *************************************************************

skipping: no hosts matched

PLAY RECAP *********************************************************************

node1 : ok=3 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0


     

Banshee091

unread,
Apr 3, 2021, 6:22:55 AM4/3/21
to AWX Project
I assume your variables are getting deleted after the first playbook. I had a similar experience in a play which uses variables for the second playbook. You might consider setting temporary facts on source_host and access them in the second play via "{{ hostvars['source_host][fact_name] }}".
Tbh, I'm not an expert an am still learning ansible and awx, but this might fix your problem.
Reply all
Reply to author
Forward
0 new messages