How to extract a hostname with the largest number and use that hostname in the mount command as shown below? Basically, I have only one volume that needs to be mounted across all hosts in the group and the volume is created with the hostname with the largest number if that makes sense.
server1
server2
vol_server2 => need to be mounted on server1 and 2.
The mymount variable is set globally
The mymontvol var is set in the local role vars file
mymountvol: storage:/{{ inventory_hostname }}_dbfiles
Here is the mount task:
- name: mount volume
mount:
name: "{{ mymount }}"
state: mounted
fstype: nfs
src: "{{ mymountvol }}"
opts: rw,bg,hard,nointr,nolock,noatime
when: mymount is defined and mymountvol is defined
become: true
become_user: root