-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vmware.vcenter_folder: does not create folder at the root when a 'subfolder' with the same name already exists #2054
Comments
My colleague reported that inside vcenter_folder.py, is the only thing that changed between the versions and makes it likely the cause of the issue. I am ofcourse willing to create a diff for this and a pull request, but is it something that you did on purpose and what is the reasoning behind it? |
Apparently indeed, i can also understand why, because on subfolders you might get conflicts, and especially because the abstraction is 'parent folder' together with 'folder name', which can conflict if you have test1/parent_folder/folder_name and test2/parent_folder/folder_name, because which one is the right one? The one under test1 or test2? I think the empty parent_folder though, is a special case where we say it's on the rootlevel of things, and either exists at rootlevel or not, which is different for folders with a parent folder as mentioned before. The moid is ofcourse more unique but might make it more tricky to write an abstraction in config: folders: etc will not work with moid, you need to have "key-values" and able to calculate the id of c somewhere and store that so that subfolder_d will be created on the right entity. |
SUMMARY
Initially I developed code for my employer, to create a list of folders and subfolders using community.vmware.vcenter_folder. The default version that gets installed on my test instance was 1.7.0 and that created the folders on the place I expect them to be created.
However, for work we use version 4.3.0, and there the same folder is not created as rootfolder, when a subfolder with the same name already exists.
ISSUE TYPE
COMPONENT NAME
community.vmware.vcenter_folder
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
The error can be reproduced on multiple different versions on different hardware. The version used is 1.7.0 which works and 4.3.0 that does not work.
STEPS TO REPRODUCE
run the below playbook and see the output of the task using v 4.3.0:
/home/remko/.ansible/collections/ansible_collections
Collection Version
community.vmware 4.3.0
/usr/lib/python3/dist-packages/ansible_collections
Collection Version
community.vmware 1.7.0
ansible-playbook -vvvv ./playbookfile.yaml
EXPECTED RESULTS
TASK [Create rootfolder] ********************************************************************************************************************************************************************************************
task path: /home/remko/workspace/git/scripts/ansible/projects/folders_demo/local_build_folders.yaml:14
Read vars_file 'credentials.yaml'
ESTABLISH LOCAL CONNECTION FOR USER: remko
EXEC /bin/sh -c 'echo ~remko && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "
echo /home/remko/.ansible/tmp
"&& mkdir "echo /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701
" && echo ansible-tmp-1713884307.3059566-3273653-280408203908701="echo /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701
" ) && sleep 0'Using module file /home/remko/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vcenter_folder.py
PUT /home/remko/.ansible/tmp/ansible-local-3273627121gn612/tmpcft70qyt TO /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701/AnsiballZ_vcenter_folder.py
EXEC /bin/sh -c 'chmod u+x /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701/ /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701/AnsiballZ_vcenter_folder.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/python3 /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701/AnsiballZ_vcenter_folder.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /home/remko/.ansible/tmp/ansible-tmp-1713884307.3059566-3273653-280408203908701/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=test1) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"datacenter": "vdc1",
"datacenter_name": "vdc1",
"folder_name": "test1",
"folder_type": "vm",
"hostname": "vcenter.lan.elvandar.org",
"parent_folder": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"proxy_host": null,
"proxy_port": null,
"state": "present",
"username": "[email protected]",
"validate_certs": false
}
},
"item": "test1",
"result": {
"msg": "Folder test1 already exists",
"path": "/vdc1/vm/test1"
}
}
Read vars_file 'credentials.yaml'
EXEC /bin/sh -c 'echo ~remko && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "
echo /home/remko/.ansible/tmp
"&& mkdir "echo /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747
" && echo ansible-tmp-1713884307.7591896-3273653-205672076350747="echo /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747
" ) && sleep 0'Using module file /home/remko/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vcenter_folder.py
PUT /home/remko/.ansible/tmp/ansible-local-3273627121gn612/tmpt4vo938l TO /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747/AnsiballZ_vcenter_folder.py
EXEC /bin/sh -c 'chmod u+x /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747/ /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747/AnsiballZ_vcenter_folder.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/python3 /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747/AnsiballZ_vcenter_folder.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /home/remko/.ansible/tmp/ansible-tmp-1713884307.7591896-3273653-205672076350747/ > /dev/null 2>&1 && sleep 0'
ok: [localhost] => (item=test2) => {
"ansible_loop_var": "item",
"changed": false,
"invocation": {
"module_args": {
"datacenter": "vdc1",
"datacenter_name": "vdc1",
"folder_name": "test2",
"folder_type": "vm",
"hostname": "vcenter.lan.elvandar.org",
"parent_folder": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"proxy_host": null,
"proxy_port": null,
"state": "present",
"username": "[email protected]",
"validate_certs": false
}
},
"item": "test2",
"result": {
"msg": "Folder test2 already exists",
"path": "/vdc1/vm/test2"
}
}
Read vars_file 'credentials.yaml'
EXEC /bin/sh -c 'echo ~remko && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "
echo /home/remko/.ansible/tmp
"&& mkdir "echo /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036
" && echo ansible-tmp-1713884308.0468104-3273653-57446805593036="echo /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036
" ) && sleep 0'Using module file /home/remko/.ansible/collections/ansible_collections/community/vmware/plugins/modules/vcenter_folder.py
PUT /home/remko/.ansible/tmp/ansible-local-3273627121gn612/tmpkj8ygit0 TO /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036/AnsiballZ_vcenter_folder.py
EXEC /bin/sh -c 'chmod u+x /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036/ /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036/AnsiballZ_vcenter_folder.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/python3 /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036/AnsiballZ_vcenter_folder.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /home/remko/.ansible/tmp/ansible-tmp-1713884308.0468104-3273653-57446805593036/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => (item=this_folder_should_be_on_root) => {
"ansible_loop_var": "item",
"changed": true,
"invocation": {
"module_args": {
"datacenter": "vdc1",
"datacenter_name": "vdc1",
"folder_name": "this_folder_should_be_on_root",
"folder_type": "vm",
"hostname": "vcenter.lan.elvandar.org",
"parent_folder": null,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 443,
"proxy_host": null,
"proxy_port": null,
"state": "present",
"username": "[email protected]",
"validate_certs": false
}
},
"item": "this_folder_should_be_on_root",
"result": {
"msg": "Folder 'this_folder_should_be_on_root' of type 'vm' created successfully.",
"path": "/vdc1/vm/this_folder_should_be_on_root"
}
}
ACTUAL RESULTS
Instead of adding the folder to the rootlevel (there is no parent specified), the command now sees there is a subfolder somewhere with the same name and does not create it anymore. While I can understand that potentially for subfolders (how to track them, and where), it might be easier to use the moid for the folder and use that as either root (datacenter-1001) or subfolder location, instead of making assumptions that in this case are very much incorrect.
The text was updated successfully, but these errors were encountered: