Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks again Abhijit
On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar <[email protected]> wrote: > Thanks Abhijit, Awesome , it worked !!!! > > Only issue is > > value: "{{ r.ansible_facts.ansible_distribution }}" > when: vm_info.instance.customvalues.OS != > r.ansible_facts.ansible_distribution > > that Just give Ubuntu ... is it possible to extract the info from setup > module ie below part.. > > > "ansible_lsb": { > "codename": "bionic", > * "description": "Ubuntu 18.04.5 LTS",* > "id": "Ubuntu", > "major_release": "18", > "release": "18.04" > }, > > > > > > Hopefully that is also present in CentOS nodes that way .. so the > description part ... > > r.ansible_facts.ansible_lsb.description ? will do .. > > > On Mon, Feb 22, 2021 at 10:49 PM [email protected] <[email protected]> > wrote: > >> Thanks a lot Abhijit .. i will give it a try & report issue if any. >> >> On Monday, February 22, 2021 at 9:30:23 PM UTC-8 Abhijeet Kasurde wrote: >> >>> You can do this using dynamic inventory and delegate_to >>> >>> Here is how - >>> >>> 1. Gather facts about virtual machines >>> 2. Gather facts about custom attributes using vmware_guest_info >>> 3. Compare and change if needed >>> >>> you can see this playbook >>> >>> --- >>> - hosts: running >>> tasks: >>> - setup: >>> register: r >>> >>> - debug: >>> msg: "{{ r.ansible_facts.ansible_distribution }}" >>> >>> - name: Get custom attributes information >>> vmware_guest_info: >>> name: CentOS7_Rest >>> datacenter: Asia-Datacenter1 >>> folder: /Asia-Datacenter1/vm/ >>> register: vm_info >>> delegate_to: localhost >>> >>> - debug: >>> msg: "{{ vm_info }}" >>> >>> - name: Update OS information >>> vmware_guest_custom_attributes: >>> name: CentOS7_Rest >>> datacenter: Asia-Datacenter1 >>> folder: /Asia-Datacenter1/vm/ >>> state: present >>> attributes: >>> - name: OS >>> value: "{{ r.ansible_facts.ansible_distribution }}" >>> when: vm_info.instance.customvalues.OS != >>> r.ansible_facts.ansible_distribution >>> delegate_to: localhost >>> >>> On Tue, Feb 23, 2021 at 4:12 AM [email protected] <[email protected]> >>> wrote: >>> >>>> I will give 1 more reason .. eg someone upgrade OS from 16.04 to 20.04 >>>> .. may forget to update the custom attributes... >>>> >>>> On Monday, February 22, 2021 at 2:41:08 PM UTC-8 [email protected] >>>> wrote: >>>> >>>>> Hi >>>>> >>>>> Here are my custom attributes >>>>> >>>>> >>>>> [image: Capture.JPG] >>>>> >>>>> >>>>> Today these are populated with >>>>> community.vmware.vmware_guest_custom_attributes >>>>> >>>>> >>>>> But that is manually from the file.. it has human error possible >>>>> >>>>> eg Ubuntu 20.04 folks may type Ubuntu20.4 >>>>> >>>>> >>>>> There is facts which ansible gather has the OS info.. eg -m setup -a >>>>> "filter=ansible_distribution_version" >>>>> >>>>> >>>>> Is it somehow possible to get the OS info populated "automatically" >>>>> with a playbook .. ie update the custom attributes dynamically with real >>>>> time data ? >>>>> >>>>> Any suggestions Please ? >>>>> >>>>> Thanks >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Ansible Project" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/ansible-project/6a28a2f4-92d4-4963-8a8d-0c79c64b87cbn%40googlegroups.com >>>> <https://groups.google.com/d/msgid/ansible-project/6a28a2f4-92d4-4963-8a8d-0c79c64b87cbn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> Thanks, >>> Abhijeet Kasurde >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/653118a7-176e-48c8-921b-f23830da9534n%40googlegroups.com >> <https://groups.google.com/d/msgid/ansible-project/653118a7-176e-48c8-921b-f23830da9534n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGhW9JuCHCG5D9wisPzEafUEUm%2BykdKCm1%2BKHi_A3hX3O_1bZA%40mail.gmail.com.
