Closed mark100net closed 4 years ago
@mark100net I'm glad you are interested in ansilbe-collections. I tested your playbook and it was successful. The test results are as follows:
TASK [create resource group] ****************************************************************************************************************************************************ok: [localhost]
TASK [Create virtual network] ***************************************************************************************************************************************************changed: [localhost]
TASK [debug] ********************************************************************************************************************************************************************ok: [localhost] => {
"output": {
"changed": true,
"check_mode": false,
"failed": false,
"state": {
"address_prefixes": [
"10.0.0.0/16"
],
"etag": "W/\"24d39e33-4824-43b4-b7a0-d71c22fe7714\"",
"id": "/subscriptions/xxxxxxxxxxxx/resourceGroups/v-xisuRG/providers/Microsoft.Network/virtualNetworks/fredvnet003",
"location": "eastus",
"name": "fredvnet003",
"provisioning_state": "Succeeded",
"tags": null,
"type": "Microsoft.Network/virtualNetworks"
}
}
}
PLAY RECAP **********************************************************************************************************************************************************************localhost : ok=4 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@mark100net I suspect that your ansible and ansible-collection refer to azure-mgmt-network differently. Can you help confirm this? Thank you very much! ansible-collection: /usr/local/lib/python3.7/site-packages/azure/mgmt/network/network_management_client.py ansible: ?
@Fred-sun Thanks for trying to reproduce my issue.
I am not completely sure what you are asking. I do have network_management_client.py
in the location you specified.
My azcollection
is in ~/.ansible/collections/ansible_collections/azure/azcollection
My ansible --version
output is (sorry, I should have put that in the original issue):
config file = None
configured module search path = ['/Users/mark/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.7.7 (default, Apr 25 2020, 11:17:28) [Clang 11.0.3 (clang-1103.0.32.29)]
If that does not answer your question please let me know what I need to do to answer your question.
Thanks again.
@mark100net Can you do such a verification, edit "/usr/local/lib/python3.7/site-packages/ansible/module_utils/azure_rm_common.py". Then test with default tasks and share the fail log to me! Thank you very much!
@property
def network_client(self):
self.log('Getting network client')
if not self._network_client:
self._network_client = self.get_mgmt_svc_client(NetworkManagementClient,
base_url=self._cloud_environment.endpoints.resource_manager,
api_version='2019-07-01')
return self._network_client
@property
def network_models(self):
self.log("Getting network models...")
return NetworkManagementClient.models("2018-09-01")
Hello @Fred-sun , thanks for getting back to me.
I was not sure what you meant by "default tasks". But I made the edits you suggested and ran the playbook with the tasks above and got this fail log:
@mark100net Sorry for misunderstand to you. default tasks from the cloud/ansible module. Thank you very much!
@Fred-sun I did (also) run the task as the default (i.e. as azure_rm_virtualnetwork
without the collection qualifier). I do not get a failure that way (with or without the edits you gave me). In case it helps, here is the output when I run it with the default with the edits:
@mark100net Thank you very much for your feedback. First of all, you should definitely report an error after changing the API version, because the network API does not have these two versions. So your two task executions use different APIs. Second , that I have encountered such a similar problem, ansible and ansible-collection use azure-mgmt-network in different locations. Could you help remove ansible and ansible-collection and reinstall to retry? Thank you very much!
@Fred-sun I'm sorry, I realized the file you told me to modify was not properly saved and I was running against the original. I made the edits again and actually am getting a failure log (using the default tasks), attached below, so I hope this helps:
Thanks again.
@mark100net Thanks for your feedback! I see!
@Fred-sun Do you have any other suggestions then?
@Fred-sun Do you have any other suggestions then?
As you can see from your log, ansible and ansible-collections use the same network_management_client.py, the two test results should be the same, and you should not go wrong here. I am still thinking about how to clarify, thank you!
@mark100net Please delete “/usr/local/lib/python3.7/site-packages/azure/mgmt/network/”, reinstall azure-mgmt-network and try again, thank you!
sudo pip3 install azure-mgmt-network -I
@Fred-sun Thanks for the suggestion. I was able to get past the original error after doing your suggestion, but I got another error later on in my playbook when creating a virtual network. I will get you the details on that at a later date.
In the meantime, did you want me to do that with or without the edits to the azure_rm_common.py
file you gave me before? I get errors either way but the error is different depending on which one.
Thanks again.
without the edits to the
azure_rm_common.py
@mark100net Without the edits to the azure_rm_common.py, Thank you very much!
@Fred-sun After deleting the network
directory and reinstalling azure-mgmt-network
and running with the original azure_rm_common.py
as you suggested I am still getting the same error as originally reported with the azure.azcollection.azure_rm_vurtualnetwork
task. Output below:
Thanks again.
@mark100net Please help provide "pip3 list |grep azure-mgmt-network" information and send me these two files. Thank you!
/Users/mark/Library/Python/3.7/lib/python/site-packages/azure/mgmt/network/network_management_client.py
/Users/mark/Library/Python/3.7/lib/python/site-packages/azure/mgmt/network/_network_management_client.py
@Fred-sun here you go:
> pip3 list | grep azure-mgmt-network
azure-mgmt-network 2.3.0
I do not have a _network_management_client.py
in that directory. I have network_management_client.pay
included below (with .txt extension added to I could upload it here):
network_management_client.py.txt
Thanks
@mark100net You are using an old version of azure-mgmt-network, please delete ”/Users/mark/Library/Python/3.7/lib/python/site-packages/azure/mgmt/network“ folder and reinstall azure-mgmt-network (sudo pip3 install azure-mgmt-network==10.1.0 -I). Thank you!
@Fred-sun I am going to close this issue because clearly the problem relates to my setup. But if you have any further suggestions please let me know.
When I deleted the 'network' folder as you instructed and then ran the azure-mgmt-network
install it did not install it to the location under my home directory. It installed it to /usr/local/lib/python3.7
, and the playbook failed because it was still looking for the azure-mgmt-network
under my home directory.
Then I removed ~/Library/Python altogether and the problem went away.
Clearly this applies to me:
:(
Thanks again for all your time and help with this.
SUMMARY
ISSUE TYPE
As noted in the coment in the code below, I do not have a problem if I use the default tasks from the cloud/ansible module. But if I use the most recent code from the collection, create virtual network and several related tasks break in the same way.
COMPONENT NAME
ansible-collection version 0.1.3 installed via:
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
MacOS 10.15.4
STEPS TO REPRODUCE
Configure Azure CLI with credentials then run following tasks:
EXPECTED RESULTS
Virtual network is created in azure.
ACTUAL RESULTS