# Update custom attribute called OS

**URL:** <https://forum.ansible.com/t/update-custom-attribute-called-os/34585>\
**Category:** Ansible Project\
**Tags:** windows, vmware\
**Created:** [February 7, 2021, 5:03am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585 "2021-02-07T05:03:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [February 7, 2021, 5:03am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/1 "2021-02-07T05:03:33Z")

</div>

Hi

anyone can suggest Please if we can update the say a ‘custom attribute’ called OS from OS level with below

[https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware\_vm\_info\_module.html](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_vm_info_module.html)

Say i want to use Windows 2019 DataCenter … which is not aviable btw in vCenter 6.7 … so getting that as ansible facts and add to attributes somehow

Thanks

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2021, 6:46am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/2 "2021-02-07T06:46:30Z")

</div>

You could override the values by combining it with a specially crafter  
dictionary, or loop over it, etc.  
How exactly you do this depends on the data structure, but the module  
documentation does not mention any such custom attributes.  
If you have an example of your playbook and the resulting data structure?

---

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [February 7, 2021, 8:58am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/3 "2021-02-07T08:58:26Z")

</div>

Thanks for Reply, just to give you more context

The custom attributes i have added are

OS  
Application

Owner

Etc…

Now why OS ? That is as the OS seen by vCenter is say Ubuntu .,… but it does not tell if that is Ubuntu18.04 or Ubuntu20.04 … so i have added them manually for now… but looking for way to Automate that.

Thanks

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2021, 12:55pm UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/4 "2021-02-07T12:55:10Z")

</div>

That’s not really an example of the actual data structure. So for the moment the answer is that what you want should be possible.

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [February 8, 2021, 4:25am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/5 "2021-02-08T04:25:31Z")

</div>

Hi

You can set and get custom values like

- name: Set Custom Attributes  
community.vmware.vmware\_guest\_custom\_attributes:  
validate\_certs: False  
hostname: ‘{{ vcenter\_hostname }}’  
username: ‘{{ vcenter\_username }}’  
password: ‘{{ vcenter\_password }}’  
state: present  
name: ‘dev-1’  
attributes:

- name: OS  
value: ‘Windows Server 2019’

- name: Get guest information  
community.vmware.vmware\_guest\_info:  
validate\_certs: False  
hostname: ‘{{ vcenter\_hostname }}’  
username: ‘{{ vcenter\_username }}’  
password: ‘{{ vcenter\_password }}’  
name: ‘dev-1’  
datacenter: Asia-Datacenter1

The output will be like -

ok: [localhost] =\> {  
“changed”: false,  
“instance”: {  
“annotation”: “”,  
“current\_snapshot”: null,  
“customvalues”: {  
“OS”: “Windows Server 2019”  
},  
…

---

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [February 8, 2021, 11:46pm UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/6 "2021-02-08T23:46:51Z")

</div>

Thanks for Reply Abhijit … i already saw ur module - community.vmware.vmware\_guest\_custom\_attributes

I am doing this already which powershell with one liner

Get-VM $($line.name) |Set-Annotation -CustomAttribute “OS” -Value $($line.os)

The power of ansible is it can talk on OS level & Vmware powercli does only on vCenter level

vCenter sees OS os with Vmwre-tools as CentOS7 … ok gr8 … but when it comes to say Ubuntu it simply says Ubuntu 64 bit & not Ubuntu18

Now we know with Ansible “fatcs & filter” we can get OS details … so that can somehow read & push into custom attributes ? If yes that will be awesome.

ansible all -m setup -a “filter=ansible\_distribution\_version” -o

Thanks

---

<div class="post-metadata">

**Author:** ![Kiran\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kiran\_Kumar](https://forum.ansible.com/u/Kiran_Kumar)\
**Post date:** [February 10, 2021, 5:39am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/7 "2021-02-10T05:39:35Z")

</div>

So again experts & it could be a feature request …

## How can we dynamicailly update OS custome attribute

- name: Set Custom Attributes  
community.vmware.vmware\_guest\_custom\_attributes:  
validate\_certs: False  
hostname: ‘{{ vcenter\_hostname }}’  
username: ‘{{ vcenter\_username }}’  
password: ‘{{ vcenter\_password }}’  
state: present  
name: ‘dev-1’  
attributes:
- name: OS  
value: ‘Windows Server 2019’

ansible all -m setup -a “filter=ansible\_distribution\_version” -o =====\>\> can be used as “value” in above ?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 10, 2021, 7:53am UTC](https://forum.ansible.com/t/update-custom-attribute-called-os/34585/8 "2021-02-10T07:53:57Z")

</div>

Can you be more clear in what you are actually trying to achieve?  
What problem are you exactly having?  
Share a playbook or inventory that does not do what you want, for example.
