Skip to content
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: Colon support within VMWare Tags vmware_tag_manager #65765

Closed
limitedreality opened this issue Dec 12, 2019 · 13 comments · Fixed by #66150
Closed

VMware: Colon support within VMWare Tags vmware_tag_manager #65765

limitedreality opened this issue Dec 12, 2019 · 13 comments · Fixed by #66150
Assignees
Labels
affects_2.10 This issue/PR affects Ansible v2.10 cloud feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community

Comments

@limitedreality
Copy link

limitedreality commented Dec 12, 2019

SUMMARY

VMWare supports using colons in VMWare tags, however the vmware_tag_manager module does not since colons are used to delineate categories. It would be nice if there was some way to support using colons in tag names.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

vmware_tag_manager

ADDITIONAL INFORMATION

There should be some way to escape a colon in a tag_name so that we can continue to support categories but intentionally override that functionality when we intend to use a tag with a colon within. Two tag examples below. One with category, one escaping for instance. Feel free to use whatever escape sequence is most supportable.

    vmware_tag_manager:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      validate_certs: no
      tag_names:
        -  'Category:Tag'
        -  'TagWith\:Colon'
      object_name: 'VMGuest'
      object_type: VirtualMachine
      state: add
    delegate_to: localhost

Including the authors:
@Akasurde
@GBrawl

@ansibot
Copy link
Contributor

ansibot commented Dec 12, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Dec 12, 2019

@ansibot
Copy link
Contributor

ansibot commented Dec 12, 2019

@limitedreality, just so you are aware we have a dedicated Working Group for vmware.
You can find other people interested in this in #ansible-vmware on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 cloud feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Dec 12, 2019
@GBrawl
Copy link
Contributor

GBrawl commented Dec 12, 2019

As of right now category and tag name are indeed separated by ":", but note that this string is only split once, so currently as a workaround you could specify the category name and then you could use colons in your tag name. For example:

    vmware_tag_manager:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      validate_certs: no
      tag_names:
        -  'category:tag:with:colon'
      object_name: 'VMGuest'
      object_type: VirtualMachine
      state: add
    delegate_to: localhost

But escaping sounds like a good idea for when there is no category name given.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Dec 12, 2019
@limitedreality
Copy link
Author

limitedreality commented Dec 12, 2019

@GBrawl Great idea, but unfortunately that fails for me stating InvalidArgument. Basically it's saying the tag_names dict object has no attribute set now.

Are you able to test and confirm working on your side?

@GBrawl
Copy link
Contributor

GBrawl commented Dec 12, 2019

Just tested it and it works fine on ansible 2.9.2, can you show me the task you are trying to run? Also you can't have colons in your category name with this approach.

@limitedreality
Copy link
Author

limitedreality commented Dec 12, 2019

Here's what I'm using with: Ansible 2.8.0

  - name: Add tags to a virtual machine
    vmware_tag_manager:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      validate_certs: no
      tag_names:
        -  'Category:Tag:Name'
      object_name: 'TestGuest'
      object_type: VirtualMachine
      state: add
    delegate_to: localhost

I know that I'm using the category:name syntax properly as when I apply a tag in that category without a colon it works fine.

Interestingly, it seems that it is parsing the tag name properly because if I change the tag name portion to something that doesn't exist (including a colon), it errors saying unable to find that tag.

It's only when I supply a valid tag with a colon that it appears to fail. So maybe something specific to the application of the tag?

File \"/usr/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py\", line 345, in _invoke\n    
return self._api_interface.native_invoke(ctx, _method_name, kwargs)\n  
File \"/usr/lib/python3.6/site-packages/vmware/vapi/bindings/stub.py\", line 298, in native_invoke\n    
self._rest_converter_mode)\ncom.vmware.vapi.std.errors_client.InvalidArgument: {messages : [], data : None, error_type : None}\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

TASK [debug] ***********************************************************************************************************************************************************************************************
task path: /etc/ansible/playbooks/add_vmware_tag.yml:21
fatal: [IP-REMOVED]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout_lines'\n\nThe error appears to be in '/etc/ansible/playbooks/add_vmware_tag.yml': line 21, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - debug: msg=\"{{ out.stdout_lines }}\"\n    ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n    with_items:\n      - {{ foo }}\n\nShould be written as:\n\n    with_items:\n      - \"{{ foo }}\"\n"

@GBrawl
Copy link
Contributor

GBrawl commented Dec 12, 2019

Tried it on 2.8.4 and that also worked for me and your example looks correct, if both the category and the tag name exist it should work. Are you running vSphere 6.5 or higher?

@limitedreality
Copy link
Author

Yes vSphere 6.5

@limitedreality
Copy link
Author

We updated to Ansible 2.8.7 to see if that would help and the results are the same. Anyone have any other thoughts or suggestions? Any further way to debug why we're seeing different results than GBrawl?

Akasurde added a commit to Akasurde/ansible that referenced this issue Jan 1, 2020
User can now specify tag and category using dict in vmware_tag_manager
module. This is useful when tag or category name contains colon.

Fixes: ansible#65765

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde
Copy link
Member

Akasurde commented Jan 1, 2020

resolved_by_pr #66150

@Akasurde
Copy link
Member

Akasurde commented Jan 1, 2020

@limitedreality, Could you please check PR #66150 and let us know if it works for you ?

Please check How to test a PR for more help.

Thanks.

needs_info

@Akasurde Akasurde self-assigned this Jan 1, 2020
@Akasurde Akasurde changed the title Colon support within VMWare Tags vmware_tag_manager VMware: Colon support within VMWare Tags vmware_tag_manager Jan 1, 2020
@ansibot ansibot added has_pr This issue has an associated PR. needs_info This issue requires further information. Please answer any outstanding questions. labels Jan 1, 2020
Akasurde added a commit to Akasurde/ansible that referenced this issue Jan 14, 2020
User can now specify tag and category using dict in vmware_tag_manager
module. This is useful when tag or category name contains colon.

Fixes: ansible#65765

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot
Copy link
Contributor

ansibot commented Feb 2, 2020

@limitedreality This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

goneri pushed a commit that referenced this issue Feb 14, 2020
User can now specify tag and category using dict in vmware_tag_manager
module. This is useful when tag or category name contains colon.

Fixes: #65765

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansible ansible locked and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 cloud feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants