Forum Discussion
Modify vCMP-Guest with ansible not possible?
- Feb 17, 2023
Hello Matt_Mabis ,
thank you for your answer.
I can confirm, that one can add VLANs to a vcmp-guest like this, but:You have to list all the existing vlans next to the new one as well. You can't just add a new one. The module replaces all VLANs of the guest with the ones listed in the "vlans" section of the module.
I find this rather awkward. To add a VLAN to a guest, without knowing or careing what VLANs were configured previosly you had to:- Use module bigip_device_info to query information about all vCMP-guest on a vCMP-Host
- Filter the output by the name of the vCMP-Guest you like to update and get the list of currently configured vlans
- append the new vlan to the list
- apply the extended list to the guest
vars: guest_to_modify: "Guest1" vlan_tobe_added: "/Common/fancy-new-vlan" tasks: - name: Get vCMP-Guest Info bigip_device_info: gather_subset: - vcmp-guests provider: "{{ bigip_provider }}" register: device_info delegate_to: localhost - name: Filter for specific guest and build a list with new vlan set_fact: list_current_vlans: "{{ device_info.vcmp_guests|selectattr('full_path', 'match', guest_to_modify) | map(attribute='vlans') }}" list_with_added_vlan: "{{ list_current_vlans[0] + [vlan_tobe_added] }}" - name: Add VLAN to vCMP-Guest bigip_vcmp_guest: name: "{{ guest }}" vlans: "{{ list_with_added_vlan }}" provider: "{{ bigip_provider }}" delegate_to: localhost
Anyway. I tested it and it worked for me. the abillity to just add a new vlan would be better i guess, but I'll take it.
Thank you very much!
Hello Matt_Mabis ,
thank you for your answer.
I can confirm, that one can add VLANs to a vcmp-guest like this, but:
You have to list all the existing vlans next to the new one as well. You can't just add a new one. The module replaces all VLANs of the guest with the ones listed in the "vlans" section of the module.
I find this rather awkward. To add a VLAN to a guest, without knowing or careing what VLANs were configured previosly you had to:
- Use module bigip_device_info to query information about all vCMP-guest on a vCMP-Host
- Filter the output by the name of the vCMP-Guest you like to update and get the list of currently configured vlans
- append the new vlan to the list
- apply the extended list to the guest
vars:
guest_to_modify: "Guest1"
vlan_tobe_added: "/Common/fancy-new-vlan"
tasks:
- name: Get vCMP-Guest Info
bigip_device_info:
gather_subset:
- vcmp-guests
provider: "{{ bigip_provider }}"
register: device_info
delegate_to: localhost
- name: Filter for specific guest and build a list with new vlan
set_fact:
list_current_vlans: "{{ device_info.vcmp_guests|selectattr('full_path', 'match', guest_to_modify) | map(attribute='vlans') }}"
list_with_added_vlan: "{{ list_current_vlans[0] + [vlan_tobe_added] }}"
- name: Add VLAN to vCMP-Guest
bigip_vcmp_guest:
name: "{{ guest }}"
vlans: "{{ list_with_added_vlan }}"
provider: "{{ bigip_provider }}"
delegate_to: localhost
Anyway. I tested it and it worked for me. the abillity to just add a new vlan would be better i guess, but I'll take it.
Thank you very much!
Totally understand where you are coming from, I think they would have had to create a different module for that scenario. The removal of a vlan would have created complications against bigip_vcmp_guests module as a "absent" status trying to remove a vlan would probably tell the system to remove the entire guest not just a vlan..
Glad you were able to figure out a solution.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com