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 
Any finding I will report here 
 

On Tuesday, October 23, 2018 at 12:30:39 AM UTC+8, Tony Chia wrote:
>
> Another thing you can try is to force refresh the dynamic inventory using 
> the meta module like this
>
> - name: Refresh inventory to ensure new instaces exist in inventory
>   meta: refresh_inventory
>
>
> https://docs.ansible.com/ansible/2.7/modules/meta_module.html
>
> On Sunday, October 21, 2018 at 11:59:05 PM UTC-7, Johar K. Kwan wrote:
>>
>> 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
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3176d895-2a15-493a-88a7-6ed38350c48c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to