Hello,
I am trying to configure a playbook for setting up nodes in an open stack cluster. As part of the openstack cluster, you can pass a “group” variable which will put nodes in the group on different compute nodes. We already have a naming convention that allows us to do this fairly easily.
For example, our database servers are named loc-env-ssdb-01, loc-env-ssdb-02, loc-env-ssdb-03, etc.
Since we want all the db servers on different compute nodes, we should just be able to pass the node name, trimmed of the last three characters, into the group value. This would keep the vms on different hosts. However, I can’t find a great way to do this in the YAML file.
Here is what I have so far:
nova_compute:
state: present
login_username: ‘{{ tenant_username }}’
login_password: ‘{{ tenant_password }}’
login_tenant_name: ‘{{ tenant_env }}’
auth_url: ‘{{ auth_url }}’
flavor_id: ‘{{ flavor_id }}’
key_name: ‘{{ keypair_name }}’
name: ‘{{ item.vm_name }}’
wait_for: 440
image_id: ‘{{ image.id }}’
nics:
- net-id: ‘{{ network_id }}’
userdata: ‘{{ userdata }}’
meta: #‘{{item.meta }}’
group: ‘{{ item.vm_name }}’ # This is where I want a regex or something to trim the last 3 characters from the vm name and pass that in as the group.
#role: ‘{{ item.meta.role }}’
register: vm
with_items: vms
Any help would be appreciated.
Thanks,
Danny