Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Kiran Kumar
Ok this one was easy .. just did below

value: "{{ r.ansible_facts.ansible_distribution }}{{
r.ansible_facts.ansible_distribution_version }}"

Thanks again Abhi & Stefan Hornburg (Racke)

On Wed, Feb 24, 2021 at 10:11 AM Kiran Kumar  wrote:

> "{{ r.ansible_facts.ansible_distribution ~ ' ' ~
> r.ansible_facts.ansible_distribution_version }}" , works
>
>
> it gives
>
> Ubuntu 18.04
>
> How to get
>
> Ubuntu18.04
>
> Ie remove the space ?
>
> Will try few things ..  Any docs Please on this ?  where you go these .. ~
> ' ' ~ :)
>
> BTW yes, "{{ r.ansible_facts.ansible_distribution }} {{
> r.ansible_facts.ansible_distribution_version }}"  , worked too , even that
> add that space ...
>
>
>
> On Wed, Feb 24, 2021 at 2:15 AM Abhijeet Kasurde 
> wrote:
>
>> how about -
>> "{{ r.ansible_facts.ansible_distribution ~ ' ' ~
>> r.ansible_facts.ansible_distribution_version }}"
>>
>> On Wed, Feb 24, 2021 at 3:36 PM Kiran Kumar  wrote:
>>
>>>
>>> Setup gives :
>>>
>>> "ansible_distribution": "Ubuntu",
>>> "ansible_distribution_file_parsed": true,
>>> "ansible_distribution_file_path": "/etc/os-release",
>>> "ansible_distribution_file_variety": "Debian",
>>> "ansible_distribution_major_version": "18",
>>> "ansible_distribution_release": "bionic",
>>> "ansible_distribution_version": "18.04",
>>>
>>>
>>>
>>> I would like to use OS name as
>>>
>>> Ubuntu20.04 & not Ubuntu 20.04.2 LTS
>>>
>>> So tried below .. as *value *.. all 3 failed .. any suggestions Please,
>>> on how to concatenate  ?
>>>
>>> ###
>>>
>>> The offending line appears to be:
>>>
>>> - name: OS
>>>   value: "{{ r.ansible_facts.ansible_distribution }}" "{{
>>> r.ansible_facts.ansible_distribution_version }}"
>>>   ^ here
>>> We could be wrong, but this one looks like it might be an issue with
>>> missing quotes. Always quote template expression brackets when they
>>> start a value. For instance:
>>>
>>> with_items:
>>>   - {{ foo }}
>>>
>>> Should be written as:
>>>
>>> with_items:
>>>   - "{{ foo }}"
>>> ###
>>> The offending line appears to be:
>>>
>>> - name: OS
>>>   value: "{{ r.ansible_facts.ansible_distribution }}"+"{{
>>> r.ansible_facts.ansible_distribution_version }}"
>>>  ^ here
>>> We could be wrong, but this one looks like it might be an issue with
>>> missing quotes. Always quote template expression brackets when they
>>> start a value. For instance:
>>>
>>> with_items:
>>>   - {{ foo }}
>>>
>>> Should be written as:
>>>
>>> with_items:
>>>   - "{{ foo }}"
>>>
>>> ###
>>> {"msg": "template error while templating string: expected token 'end of
>>> print statement', got 'r'. String: {{ r.ansible_facts.ansible_distribution
>>> r.ansible_facts.ansible_distribution_version }}"}
>>>
>>> ###
>>>
>>> On Wed, Feb 24, 2021 at 12:24 AM Kiran Kumar  wrote:
>>>
 Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks
 again Abhijit

 On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar 
 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 esxi...@gmail.com 
> 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: 

Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Kiran Kumar
 "{{ r.ansible_facts.ansible_distribution ~ ' ' ~
r.ansible_facts.ansible_distribution_version }}" , works


it gives

Ubuntu 18.04

How to get

Ubuntu18.04

Ie remove the space ?

Will try few things ..  Any docs Please on this ?  where you go these .. ~
' ' ~ :)

BTW yes, "{{ r.ansible_facts.ansible_distribution }} {{
r.ansible_facts.ansible_distribution_version }}"  , worked too , even that
add that space ...



On Wed, Feb 24, 2021 at 2:15 AM Abhijeet Kasurde 
wrote:

> how about -
> "{{ r.ansible_facts.ansible_distribution ~ ' ' ~
> r.ansible_facts.ansible_distribution_version }}"
>
> On Wed, Feb 24, 2021 at 3:36 PM Kiran Kumar  wrote:
>
>>
>> Setup gives :
>>
>> "ansible_distribution": "Ubuntu",
>> "ansible_distribution_file_parsed": true,
>> "ansible_distribution_file_path": "/etc/os-release",
>> "ansible_distribution_file_variety": "Debian",
>> "ansible_distribution_major_version": "18",
>> "ansible_distribution_release": "bionic",
>> "ansible_distribution_version": "18.04",
>>
>>
>>
>> I would like to use OS name as
>>
>> Ubuntu20.04 & not Ubuntu 20.04.2 LTS
>>
>> So tried below .. as *value *.. all 3 failed .. any suggestions Please,
>> on how to concatenate  ?
>>
>> ###
>>
>> The offending line appears to be:
>>
>> - name: OS
>>   value: "{{ r.ansible_facts.ansible_distribution }}" "{{
>> r.ansible_facts.ansible_distribution_version }}"
>>   ^ here
>> We could be wrong, but this one looks like it might be an issue with
>> missing quotes. Always quote template expression brackets when they
>> start a value. For instance:
>>
>> with_items:
>>   - {{ foo }}
>>
>> Should be written as:
>>
>> with_items:
>>   - "{{ foo }}"
>> ###
>> The offending line appears to be:
>>
>> - name: OS
>>   value: "{{ r.ansible_facts.ansible_distribution }}"+"{{
>> r.ansible_facts.ansible_distribution_version }}"
>>  ^ here
>> We could be wrong, but this one looks like it might be an issue with
>> missing quotes. Always quote template expression brackets when they
>> start a value. For instance:
>>
>> with_items:
>>   - {{ foo }}
>>
>> Should be written as:
>>
>> with_items:
>>   - "{{ foo }}"
>>
>> ###
>> {"msg": "template error while templating string: expected token 'end of
>> print statement', got 'r'. String: {{ r.ansible_facts.ansible_distribution
>> r.ansible_facts.ansible_distribution_version }}"}
>>
>> ###
>>
>> On Wed, Feb 24, 2021 at 12:24 AM Kiran Kumar  wrote:
>>
>>> Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks again
>>> Abhijit
>>>
>>> On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar  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 esxi...@gmail.com 
 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: "{{ 

Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Abhijeet Kasurde
how about -
"{{ r.ansible_facts.ansible_distribution ~ ' ' ~
r.ansible_facts.ansible_distribution_version }}"

On Wed, Feb 24, 2021 at 3:36 PM Kiran Kumar  wrote:

>
> Setup gives :
>
> "ansible_distribution": "Ubuntu",
> "ansible_distribution_file_parsed": true,
> "ansible_distribution_file_path": "/etc/os-release",
> "ansible_distribution_file_variety": "Debian",
> "ansible_distribution_major_version": "18",
> "ansible_distribution_release": "bionic",
> "ansible_distribution_version": "18.04",
>
>
>
> I would like to use OS name as
>
> Ubuntu20.04 & not Ubuntu 20.04.2 LTS
>
> So tried below .. as *value *.. all 3 failed .. any suggestions Please,
> on how to concatenate  ?
>
> ###
>
> The offending line appears to be:
>
> - name: OS
>   value: "{{ r.ansible_facts.ansible_distribution }}" "{{
> r.ansible_facts.ansible_distribution_version }}"
>   ^ here
> We could be wrong, but this one looks like it might be an issue with
> missing quotes. Always quote template expression brackets when they
> start a value. For instance:
>
> with_items:
>   - {{ foo }}
>
> Should be written as:
>
> with_items:
>   - "{{ foo }}"
> ###
> The offending line appears to be:
>
> - name: OS
>   value: "{{ r.ansible_facts.ansible_distribution }}"+"{{
> r.ansible_facts.ansible_distribution_version }}"
>  ^ here
> We could be wrong, but this one looks like it might be an issue with
> missing quotes. Always quote template expression brackets when they
> start a value. For instance:
>
> with_items:
>   - {{ foo }}
>
> Should be written as:
>
> with_items:
>   - "{{ foo }}"
>
> ###
> {"msg": "template error while templating string: expected token 'end of
> print statement', got 'r'. String: {{ r.ansible_facts.ansible_distribution
> r.ansible_facts.ansible_distribution_version }}"}
>
> ###
>
> On Wed, Feb 24, 2021 at 12:24 AM Kiran Kumar  wrote:
>
>> Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks again
>> Abhijit
>>
>> On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar  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 esxi...@gmail.com 
>>> 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 esxi...@gmail.com 
> 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 esxi...@gmail.com
>> wrote:
>>
>>> Hi
>>>
>>> Here are my custom attributes
>>>
>>>
>>> [image: Capture.JPG]
>>>
>>>
>>> Today these are populated with
>>> 

Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Stefan Hornburg (Racke)
On 2/24/21 11:04 AM, Kiran Kumar wrote:
> 
> Setup gives :
> 
>         "ansible_distribution": "Ubuntu",
>         "ansible_distribution_file_parsed": true,
>         "ansible_distribution_file_path": "/etc/os-release",
>         "ansible_distribution_file_variety": "Debian",
>         "ansible_distribution_major_version": "18",
>         "ansible_distribution_release": "bionic",
>         "ansible_distribution_version": "18.04",
> 
> 
> 
> I would like to use OS name as
> 
> Ubuntu20.04 & not Ubuntu 20.04.2 LTS
> 
> So tried below .. as /*value */.. all 3 failed .. any suggestions Please, on 
> how to concatenate  ?
> 
> ###
> 
> The offending line appears to be:
> 
>         - name: OS
>           value: "{{ r.ansible_facts.ansible_distribution }}" "{{ 
> r.ansible_facts.ansible_distribution_version }}"
>                                                               ^ here

This should do the trick:

value: "{{ r.ansible_facts.ansible_distribution }} {{ 
r.ansible_facts.ansible_distribution_version }}"

Regards
  racke

> We could be wrong, but this one looks like it might be an issue with
> missing quotes. Always quote template expression brackets when they
> start a value. For instance:
> 
>     with_items:
>       - {{ foo }}
> 
> Should be written as:
> 
>     with_items:
>       - "{{ foo }}"
> ###
> The offending line appears to be:
> 
>         - name: OS
>           value: "{{ r.ansible_facts.ansible_distribution }}"+"{{ 
> r.ansible_facts.ansible_distribution_version }}"
>                                                              ^ here
> We could be wrong, but this one looks like it might be an issue with
> missing quotes. Always quote template expression brackets when they
> start a value. For instance:
> 
>     with_items:
>       - {{ foo }}
> 
> Should be written as:
> 
>     with_items:
>       - "{{ foo }}"
> 
> ###
> {"msg": "template error while templating string: expected token 'end of print 
> statement', got 'r'. String: {{
> r.ansible_facts.ansible_distribution 
> r.ansible_facts.ansible_distribution_version }}"}
> 
> ###
> 
> On Wed, Feb 24, 2021 at 12:24 AM Kiran Kumar  > wrote:
> 
> Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks again 
> Abhijit
> 
> On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar  > 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 esxi...@gmail.com 
>   > 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: "{{ 

Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Kiran Kumar
Setup gives :

"ansible_distribution": "Ubuntu",
"ansible_distribution_file_parsed": true,
"ansible_distribution_file_path": "/etc/os-release",
"ansible_distribution_file_variety": "Debian",
"ansible_distribution_major_version": "18",
"ansible_distribution_release": "bionic",
"ansible_distribution_version": "18.04",



I would like to use OS name as

Ubuntu20.04 & not Ubuntu 20.04.2 LTS

So tried below .. as *value *.. all 3 failed .. any suggestions Please, on
how to concatenate  ?

###

The offending line appears to be:

- name: OS
  value: "{{ r.ansible_facts.ansible_distribution }}" "{{
r.ansible_facts.ansible_distribution_version }}"
  ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:

with_items:
  - {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"
###
The offending line appears to be:

- name: OS
  value: "{{ r.ansible_facts.ansible_distribution }}"+"{{
r.ansible_facts.ansible_distribution_version }}"
 ^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:

with_items:
  - {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"

###
{"msg": "template error while templating string: expected token 'end of
print statement', got 'r'. String: {{ r.ansible_facts.ansible_distribution
r.ansible_facts.ansible_distribution_version }}"}

###

On Wed, Feb 24, 2021 at 12:24 AM Kiran Kumar  wrote:

> Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks again
> Abhijit
>
> On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar  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 esxi...@gmail.com 
>> 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 esxi...@gmail.com 
 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 esxi...@gmail.com
> 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 

Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Kiran Kumar
Wow r.ansible_facts.ansible_lsb.description did worked !!! Thanks again
Abhijit

On Wed, Feb 24, 2021 at 12:17 AM Kiran Kumar  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 esxi...@gmail.com 
> 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 esxi...@gmail.com 
>>> 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 esxi...@gmail.com
 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 ansible-proje...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/ansible-project/6a28a2f4-92d4-4963-8a8d-0c79c64b87cbn%40googlegroups.com
 
 .

>>>
>>>
>>> --
>>> 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 ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/653118a7-176e-48c8-921b-f23830da9534n%40googlegroups.com
>> 
>> .
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGhW9JuCHCG5D9wisPzEafUEUm%2BykdKCm1%2BKHi_A3hX3O_1bZA%40mail.gmail.com.


Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-24 Thread Kiran Kumar
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 esxi...@gmail.com 
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 esxi...@gmail.com 
>> 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 esxi...@gmail.com
>>> 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 ansible-proje...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/6a28a2f4-92d4-4963-8a8d-0c79c64b87cbn%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>> --
>> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/653118a7-176e-48c8-921b-f23830da9534n%40googlegroups.com
> 
> .
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGhW9Jtmn%3DxpgXtSgaNuGcw3bjsa_jQSW0ggv_AAtvf9y%2BM5uA%40mail.gmail.com.


Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-22 Thread esxi...@gmail.com
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 esxi...@gmail.com  
> 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 esxi...@gmail.com 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 ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/6a28a2f4-92d4-4963-8a8d-0c79c64b87cbn%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/653118a7-176e-48c8-921b-f23830da9534n%40googlegroups.com.


Re: [ansible-project] Re: Automate Custome Attribute Population - Vmware

2021-02-22 Thread Abhijeet Kasurde
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 esxi...@gmail.com 
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 esxi...@gmail.com 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6a28a2f4-92d4-4963-8a8d-0c79c64b87cbn%40googlegroups.com
> 
> .
>


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFwWkHptUFyB_3OnzgbhDVkenqy9t6%3Dt6aKVH4ZHjH9MOA2w9Q%40mail.gmail.com.