Third option, which I've done in a module for my own use: have an
"extra_yum_flags" option which can take a dictionary as an argument:

    - yum:
        state: installed
        name: mypkg
        extra_yum_flags:
          foo: bar
          bam: baz
          red_hat: is an operating system

In my module I also happened to allow the extra argument to be taken as
a string.  You'll have to do something like prepending '--' to all the
keys in the dict and replacing '_' with '-' or somesuch, but this is
doable.

For my money, the "extra_yum_flag='--foo bar --bam baz" option seems the
simplest.  It's not too much code, however, to notice if the argument is
a dict and deal with it appropriately.  In my code, I did:

    def parse_extra_args(args):
        parsed_args = ''

        if isinstance(args, dict):
            for k, v in args.iteritems():
                parsed_args += '--' + k.replace('_', '-') + ' ' + v
        elif isinstance(args, basestring):
            parsed_args = args

        return parsed_args

Also, you shouldn't need to parse the parameters if they're provided in
a string, no?  Just pass then straight onto the yum command:

    cmd = yum_basecmd + [extra_yum_args, 'install', pkg]

Or what have you.
--
Morgan

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to