Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify vCMP-Guest with ansible not possible?

Ichnafi
Cirrostratus
Cirrostratus

Hello fellow F5ers,

I try to build an ansible playbook that performs the following:

  1. Get Names of trunk from vCMP-Host ->  got it by using module bigip_device_info
  2. Create a new VLAN and add it to the trunk from 1. -> got it by using moule bigip_vlan
  3. Add the newly created VLAN to a vCMP-Guest -> nope...
    1. use module  bigip_vcmp_guest? Nope, only for creating new guests
    2. create vlan also on the guest using anisble? Nope, will not make VLAN usable in guest

So, is there no other way of modifying the available VLANs fpr a vCMP-Guest, than using the TMSH command to modify the guest and run it with ansible's bigip_command module? What about idempotency?

 

modify vcmp guest <guest-name> vlans add { <vlan-name> }

 

 

 

 

1 ACCEPTED SOLUTION

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:

  1. Use module bigip_device_info to query information about all vCMP-guest on a vCMP-Host
  2. Filter the output by the name of the vCMP-Guest you like to update and get the list of currently configured vlans
  3. append the new vlan to the list
  4. 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!

View solution in original post

4 REPLIES 4

Leslie_Hubertus
Community Manager
Community Manager

Hi @Ichnafi  - I see that nobody has answered your question yet, so I'm featuring it in today's Community Highlights article as an unanswered question, and sharing this with a colleague for some help. 

Matt_Mabis
F5 Employee
F5 Employee

Hey there @Ichnafi!

 

I Tested code out for myself and got it working with bigip_vcmp_guest, here is the code i used you can see the first and second tasks creates 2 VCMP Guest Instances and the 3rd task of code modifies the existing created VCMP Guest, no ping loss no packet drops from my testing.

 

---
- hosts: localhost
  connection: local
  gather_facts: false
  vars_files:
    - /git/vars/lab/vault.yml
  tasks:

  - name: Create a vCMP guest with specific VLANs
    bigip_vcmp_guest:
      name: foo
      mgmt_network: bridged
      mgmt_address: 192.168.1.60/24
      mgmt_route: 192.168.1.1
      vlans:
        - VLAN5
      initial_image: "BIGIP-15.1.0.4-0.0.6.iso"
      provider:
        password: "{{ f5_password }}"
        server: 192.168.1.50
        user: "{{ f5_username }}"
        validate_certs: false
    delegate_to: localhost

  - name: Create a vCMP guest with specific VLANs
    bigip_vcmp_guest:
      name: Testbip
      mgmt_network: bridged
      mgmt_address: 192.168.1.61/24
      mgmt_route: 192.168.1.1
      initial_image: "BIGIP-15.1.0.4-0.0.6.iso"
      vlans:
        - VLAN2101
      state: configured
      provider:
        password: "{{ f5_password }}"
        server: 192.168.1.50
        user: "{{ f5_username }}"
        validate_certs: false
    delegate_to: localhost

  - name: Modify a vCMP guest with specific VLANs
    bigip_vcmp_guest:
      name: foo
      vlans:
        - VLAN5
        - VLAN2101
      provider:
        password: "{{ f5_password }}"
        server: 192.168.1.50
        user: "{{ f5_username }}"
        validate_certs: false
    delegate_to: localhost

 

Output from Code Run

Matt_Mabis_0-1676580573670.png

Matt_Mabis_0-1676583755508.png

Ansible Playbook Version - 2.14.1

Ansible Galaxy Collection - 1.21.0

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:

  1. Use module bigip_device_info to query information about all vCMP-guest on a vCMP-Host
  2. Filter the output by the name of the vCMP-Guest you like to update and get the list of currently configured vlans
  3. append the new vlan to the list
  4. 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.