You can create your own filter.  I've created this one that you should 
easily be able to modify to suit your needs.

import math
import collections
from ansible import errors

def uppercase_all(arg):
     return arg.upper()

def extract_siteid(arg):
    if len(arg) < 10:
        return FALSE
    site_id = arg[:7]
    return site_id

def extract_datacenter(arg):
    if len(arg) < 10:
        return FALSE
    datacenter = arg[7:10]
    return datacenter






class FilterModule(object):
     def filters(self):
         return {'uppercase_all': uppercase_all, 'extract_siteid': 
extract_siteid, 'extract_datacenter': extract_datacenter}




On Tuesday, January 2, 2018 at 11:53:03 AM UTC-6, Yz Xyz wrote:
>
> Hi - I want to create 3 variables based on hostname. These variables will 
> be used inside other tasks.
>
> Host Pattern: mabos<qa1><component><nodenum>
> Ex: mabosqa1was01
>
> what is the best way to create variables and use for subsequent task  on 
> host  ?
>
> should I write 3 different shell scripts to register appropriate variables 
> ?
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/82aa02d2-d9b7-443a-93a0-1a842ed38af3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to