IBM-Cloud / ansible-collection-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
70 stars 73 forks source link

fixing issues while checking powerVS network #114

Closed ghatwala closed 1 year ago

ghatwala commented 1 year ago

To resolve issue mentioned here https://github.com/IBM-Cloud/ansible-collection-ibm/issues/113 Error which we were getting is below ..

fatal: [localhost]: FAILED! => {"changed": false, "failed_when_result": true, "msg": "", "rc": 1, "resource": {"_name": "ansible_20230713-101802", "_type": "ibm_pi_network", "target": "ibm_pi_network.ansible_20230713-101802"}, "stderr": "\nError: failed to perform Get Network Operation for Network id ansible-demo-power-vm-network with error [GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][404] pcloudNetworksGetNotFound  &{Code:0 Description:The network ID ansible-demo-power-vm-network could not be found on cloud instance 8235eb2d80ca4b96aaa6633a2eb771b6. Ensure the ID is correct and try again. If the error persists, contact support. Error:item not found Message:}\n\n  on ibm_pi_network_ansible_20230713-101802.tf line 1, in data \"ibm_pi_network\" \"ansible_20230713-101802\":\n   1: data ibm_pi_network \"ansible_20230713-101802\" {\n\n\n", "stderr_lines": ["", "Error: failed to perform Get Network Operation for Network id ansible-demo-power-vm-network with error [GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][404] pcloudNetworksGetNotFound  &{Code:0 Description:The network ID ansible-demo-power-vm-network could not be found on cloud instance 8235eb2d80ca4b96aaa6633a2eb771b6. Ensure the ID is correct and try again. If the error persists, contact support. Error:item not found Message:}", "", "  on ibm_pi_network_ansible_20230713-101802.tf line 1, in data \"ibm_pi_network\" \"ansible_20230713-101802\":", "   1: data ibm_pi_network \"ansible_20230713-101802\" {", "", ""], "stdout": "data.ibm_pi_network.ansible_20230713-101802: Refreshing state...\n", "stdout_lines": ["data.ibm_pi_network.ansible_20230713-101802: Refreshing state..."]}

As error message has been changed in IBM cloud api calls , hence we had to add - "Error:item not found" message.

ghatwala commented 1 year ago

logs for confirmation ...

$ ansible-playbook create.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: Collection ibm.cloudcollection does not support Ansible version 2.14.5

PLAY [POWER VSI Creation Demo] *************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************
ok: [localhost]

TASK [Check for existing SSH Key] **********************************************************************************************
ok: [localhost]

TASK [Save existing SSH Key as fact] *******************************************************************************************
ok: [localhost]

TASK [Add new SSH Key] *********************************************************************************************************
skipping: [localhost]

TASK [Save new SSH Key as fact] ************************************************************************************************
skipping: [localhost]

TASK [Retrieve image list] *****************************************************************************************************
ok: [localhost]

TASK [Set VM image name/id dictionary fact] ************************************************************************************
ok: [localhost]

TASK [Check for existing network] **********************************************************************************************
ok: [localhost]

TASK [Save existing network as fact] *******************************************************************************************
ok: [localhost]

TASK [Add new network] *********************************************************************************************************
skipping: [localhost]

TASK [Save new network as fact] ************************************************************************************************
skipping: [localhost]

TASK [Check for existing Virtual Server Instance] ******************************************************************************
ok: [localhost]

TASK [Save existing Power VSI fact] ********************************************************************************************
ok: [localhost]

TASK [Create a POWER Virtual Server Instance] **********************************************************************************
skipping: [localhost]

TASK [Check for existing Virtual Server Instance] ******************************************************************************
skipping: [localhost]

TASK [Save new Power VSI fact] *************************************************************************************************
skipping: [localhost]

TASK [Print Public IP Address] *************************************************************************************************
ok: [localhost] => {
    "pi_instance.addresses[0].external_ip": "163.x.x.x"
}

TASK [Add VSI to Ansible inventory] ********************************************************************************************
changed: [localhost]

PLAY [Connect to VSI] **********************************************************************************************************

TASK [Wait for VSI to become reachable over SSH] *******************************************************************************
ok: [163.x.x.x]

TASK [Collect OS login message] ************************************************************************************************
changed: [163.x.x.x]

TASK [Print MOTD] **************************************************************************************************************
ok: [163.x.x.x] => {
    "os_motd.stdout_lines": []
}

PLAY RECAP *********************************************************************************************************************
163.x.x.x : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
localhost                  : ok=11   changed=1    unreachable=0    failed=0    skipped=7    rescued=0    ignored=0

[fedora@pe3-fedora31 simple-vm-power-vs]$ ssh root@163.x.x.x
Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Thu Jul 13 07:35:07 2023 from x.x.x.127
[root@ansible-demo-power-vm ~]# arch
ppc64le
ghatwala commented 1 year ago

hi @jaywcarman would you be able to merge this PR ?

jaywcarman commented 1 year ago

hi @jaywcarman would you be able to merge this PR ?

Sorry, but I am not a maintainer of this project.

@kavya498 - would you mind reviewing this change? It's very small and is contained within an example playbook (which is not auto-generated). Thanks!