# Could not match supplied host pattern issue

**URL:** <https://forum.ansible.com/t/could-not-match-supplied-host-pattern-issue/28840>\
**Category:** Ansible Project\
**Tags:** vmware, awx\
**Created:** [October 22, 2018, 6:59am UTC](https://forum.ansible.com/t/could-not-match-supplied-host-pattern-issue/28840 "2018-10-22T06:59:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johar\_K\_Kwan](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@Johar\_K\_Kwan](https://forum.ansible.com/u/Johar_K_Kwan)\
**Post date:** [October 22, 2018, 6:59am UTC](https://forum.ansible.com/t/could-not-match-supplied-host-pattern-issue/28840/1 "2018-10-22T06:59:05Z")

</div>

Hi All,

I have few Ansible tasks as follow:

1. Provisioning VM using vmware (no issue)
2. Adding new vm host into tower inventory (no issue)
3. Install new package to new VM (Issue)

My question is why Ansible can’t locate my adding new host? ( In fact I can try to ssh and successful)  
Any other step need to be perform before Ansible can see my new adding VM?

any help would be greatly appreciated

Below is the debug output

TASK [vcenter : Provision new VM (test) on XXX cluster] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
14:01:12

227  
task path:

228  
\<127.0.0.1\> ESTABLISH LOCAL CONNECTION FOR USER: awx

229  
\<127.0.0.1\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477`” && echo ansible-tmp-1540188072.18-260415385254477=“`echo $HOME/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477`” ) && sleep 0’

230  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware\_guest.py

231  
\<127.0.0.1\> PUT /var/lib/awx/.ansible/tmp/ansible-local-3S\_N0C7/tmpfyOWYa TO /var/lib/awx/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477/vmware\_guest.py

232  
\<127.0.0.1\> EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477/ /var/lib/awx/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477/vmware\_guest.py && sleep 0’

233  
\<127.0.0.1\> EXEC /bin/sh -c ‘/usr/bin/python2 /var/lib/awx/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477/vmware\_guest.py && sleep 0’

234  
\<127.0.0.1\> EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1540188072.18-260415385254477/ \> /dev/null 2\>&1 && sleep 0’

235  
changed: [localhost] =\> {

236  
“changed”: true,

237  
“instance”: {

238  
“annotation”: “”,

239  
“current\_snapshot”: null,

240  
“customvalues”: {},

241  
“guest\_consolidation\_needed”: false,

242  
“guest\_question”: null,

243  
“guest\_tools\_status”: “guestToolsRunning”,

244  
“guest\_tools\_version”: “10282”,

245  
“hw\_cores\_per\_socket”: 1,

246  
“hw\_datastores”: [

247  
“vsanDatastore”

248  
],

249  
“hw\_esxi\_host”: “X.X.X.X”,

250  
“hw\_eth0”: {

251  
“addresstype”: “assigned”,

252  
“ipaddresses”: [

253  
“X.X.X.X”

254  
],

255  
“label”: “Network adapter 1”,

256  
“macaddress”: “XXXXX”,

257  
“macaddress\_dash”: "XXXXXX…

…

370

371  
TASK [vcenter : Add custom attribute to VM] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
14:03:35

372  
task path:

373  
\<127.0.0.1\> ESTABLISH LOCAL CONNECTION FOR USER: awx

374  
\<127.0.0.1\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755`” && echo ansible-tmp-1540188215.36-97456549881755=“`echo $HOME/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755`” ) && sleep 0’

375  
Using module file /var/lib/awx/projects/\_19\_\_platform\_catalog/library/vmware\_guest\_custom\_attributes.py

376  
\<127.0.0.1\> PUT /var/lib/awx/.ansible/tmp/ansible-local-3S\_N0C7/tmpoItTxx TO /var/lib/awx/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755/vmware\_guest\_custom\_attributes.py

377  
\<127.0.0.1\> EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755/ /var/lib/awx/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755/vmware\_guest\_custom\_attributes.py && sleep 0’

378  
\<127.0.0.1\> EXEC /bin/sh -c ‘/usr/bin/python2 /var/lib/awx/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755/vmware\_guest\_custom\_attributes.py && sleep 0’

379  
\<127.0.0.1\> EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1540188215.36-97456549881755/ \> /dev/null 2\>&1 && sleep 0’

380  
changed: [localhost] =\> {

381  
“changed”: true,

382  
“custom\_attributes”: {

383  
“at\_group”: “test”

384  
},

385  
“invocation”: {

386  
“module\_args”: {

387  
“attributes”: [

388  
{

389  
“name”: “at\_group”,

390  
“value”: “test”

391  
}

392  
],

393  
“datacenter”: “Lab”,

394  
“folder”: “X/Z”,

395  
“hostname”: “XXXX”,

396  
“name”: “test”,

397  
“password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,

398  
“port”: 443,

399  
“state”: “present”,

400  
“username”: “XXXX”,

401  
“uuid”: null,

402  
“validate\_certs”: false

403  
} …

…

410

411  
TASK [vcenter : Add VM (test to cluster VM group (XXXX)] \*\*\*\*\*\*\*\*\*\*\*  
14:03:36

412  
task path:

413  
skipping: [localhost] =\> {

414  
“changed”: false,

415  
“skip\_reason”: “Conditional result was False”

416  
}

4

421

422  
TASK [Add host (test) to inventory (vcenter)] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
14:03:36

423  
task path:

424  
\<127.0.0.1\> ESTABLISH LOCAL CONNECTION FOR USER: awx

425  
\<127.0.0.1\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366`” && echo ansible-tmp-1540188216.82-116114875625366=“`echo $HOME/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366`” ) && sleep 0’

426  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/web\_infrastructure/ansible\_tower/tower\_host.py

427  
\<127.0.0.1\> PUT /var/lib/awx/.ansible/tmp/ansible-local-3S\_N0C7/tmp4J8vzx TO /var/lib/awx/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366/tower\_host.py

428  
\<127.0.0.1\> EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366/ /var/lib/awx/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366/tower\_host.py && sleep 0’

429  
\<127.0.0.1\> EXEC /bin/sh -c ‘/usr/bin/python2 /var/lib/awx/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366/tower\_host.py && sleep 0’

430  
\<127.0.0.1\> EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1540188216.82-116114875625366/ \> /dev/null 2\>&1 && sleep 0’

431  
changed: [localhost] =\> {

432  
“changed”: true,

433  
“host”: “test”,

434  
“id”: 5166,

435  
“invocation”: {

436  
“module\_args”: {

437  
“description”: null,

438  
“enabled”: true,

439  
“inventory”: “vcenter”,

440  
“name”: “test”,

441  
“state”: “present”,

442  
“variables”: “{‘ansible\_ssh\_host’: ‘X.X.X.X’}”

443  
}

444  
},

445  
“state”: “present”

446  
}

4

451

452  
TASK [Wait 300 seconds for port 22 to become open and contain “OpenSSH”] \*\*\*\*\*\*\*  
14:03:39

453  
task path:

454  
\<127.0.0.1\> ESTABLISH LOCAL CONNECTION FOR USER: awx

455  
\<127.0.0.1\> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “`echo $HOME/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443`” && echo ansible-tmp-1540188219.37-199300888008443=“`echo $HOME/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443`” ) && sleep 0’

456  
Using module file /usr/lib/python2.7/site-packages/ansible/modules/utilities/logic/wait\_for.py

457  
\<127.0.0.1\> PUT /var/lib/awx/.ansible/tmp/ansible-local-3S\_N0C7/tmpZaPj4P TO /var/lib/awx/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443/wait\_for.py

458  
\<127.0.0.1\> EXEC /bin/sh -c ‘chmod u+x /var/lib/awx/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443/ /var/lib/awx/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443/wait\_for.py && sleep 0’

459  
\<127.0.0.1\> EXEC /bin/sh -c ‘/usr/bin/python2 /var/lib/awx/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443/wait\_for.py && sleep 0’

460  
\<127.0.0.1\> EXEC /bin/sh -c ‘rm -f -r /var/lib/awx/.ansible/tmp/ansible-tmp-1540188219.37-199300888008443/ \> /dev/null 2\>&1 && sleep 0’

461  
ok: [localhost] =\> {

462  
“changed”: false,

463  
“elapsed”: 10,

464  
“invocation”: {

465  
“module\_args”: {

466  
“active\_connection\_states”: [

467  
“ESTABLISHED”,

468  
“FIN\_WAIT1”,

469  
“FIN\_WAIT2”,

470  
“SYN\_RECV”,

471  
“SYN\_SENT”,

472  
“TIME\_WAIT”

473  
],

474  
“connect\_timeout”: 5,

475  
“delay”: 10,

476  
“exclude\_hosts”: null,

477  
“host”: “test”,

478  
“msg”: null,

479  
“path”: null,

480  
“port”: 22,

481  
“search\_regex”: null,

482  
“sleep”: 1,

483  
“state”: “started”,

484  
“timeout”: 300

485  
}

486  
},

487  
“path”: …

…

492

498  
[WARNING]: Could not match supplied host pattern, ignoring: test

499

500

501  
PLAY [test] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
14:03:50

502  
skipping: no hosts matched

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [October 22, 2018, 4:15pm UTC](https://forum.ansible.com/t/could-not-match-supplied-host-pattern-issue/28840/2 "2018-10-22T16:15:30Z")

</div>

It seems your steps#1 and step#2 are in one play and step#3 is in another play?

if so the variables/facts does carry across plays.  
You can check the following article how to read the facts from previous play  
[https://stackoverflow.com/questions/48045100/how-to-use-return-values-of-one-task-in-another-task-for-a-different-host-in-ans](https://stackoverflow.com/questions/48045100/how-to-use-return-values-of-one-task-in-another-task-for-a-different-host-in-ans)

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [October 22, 2018, 4:30pm UTC](https://forum.ansible.com/t/could-not-match-supplied-host-pattern-issue/28840/3 "2018-10-22T16:30:39Z")

</div>

Another thing you can try is to force refresh the dynamic inventory using the meta module like this

```auto
- name: Refresh inventory to ensure new instaces exist in inventory
  meta: refresh_inventory

```

[https://docs.ansible.com/ansible/2.7/modules/meta\_module.html](https://docs.ansible.com/ansible/2.7/modules/meta_module.html)

---

<div class="post-metadata">

**Author:** ![Johar\_K\_Kwan](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@Johar\_K\_Kwan](https://forum.ansible.com/u/Johar_K_Kwan)\
**Post date:** [October 24, 2018, 1:06am UTC](https://forum.ansible.com/t/could-not-match-supplied-host-pattern-issue/28840/4 "2018-10-24T01:06:54Z")

</div>

Thank you Tony for pointing out meta module and hostvars unfortunetly I’m still facing same issue.  
I think I will try this method [https://groups.google.com/forum/#!topic/ansible-project/ZBP0iXLDhoc](https://groups.google.com/forum/#!topic/ansible-project/ZBP0iXLDhoc)  
Any finding I will report here
