You could probably do:
{"/usr/local": "/usr/my/local",
"/local/perl": "/usr/my/perl"}
That will work as long as order does not matter (if the replacements do not
cause there to be more or less of the replacer substrings). If you can't
guarantee that, then the list is better, although you can do single element
dicts or two element lists inside:
[{"/usr/local": "/usr/my/local"},
{"/local/perl": "/usr/my/perl"}]
[ ["/usr/local", "/usr/my/local"],
["/local/perl", "/usr/my/perl"]]
On Nov 2, 2017 11:55 AM, "ZillaYT" <[email protected]> wrote:
I'm not trying to re-invent the "replace" module that Ansible has.
I'm trying to write a (my FIRST) custom module to encapsulate the
repetitive Linux source build process, namely,
- run ./configure $CONF_OPTS
- run make
- run make $TARGETS
However, i have an outlying case where I have to modify Makefile (ugh) that
./configure produces (not my idea), so my steps are now
- run ./configure $CONF_OPTS
- modify Makefile
- run make
- run make $TARGETS
If I was writing above steps using generic Ansible modules, I'd of course
use the replace module, like so, correct? This will change all the
instances of "/usr/local" into "/usr/my/local" and "/usr/perl" into
"/usr/my/perl" in my Makefile
- name: Update Makefile (ugh)
replace:
dest: "/path_to/Makefile"
regexp: "{{item.old_str}}"
replace: "{{item.new_str}}"
with_items:
- {old_str: "/usr/local", new_str: "/usr/my/local"}
- {old_str: "/local/perl", new_str: "/usr/my/perl"}
I want my module call to look like this. Or is there a better way to
represent the "modify_regex" parameters?
- name: Run configure, make, and make targets
config_make_targets:
path: /path_to_source
modify_file: "Makefile"
modify_regex: [
{old_str: "/usr/local", new_str: "/usr/my/local"},
{old_str: "/local/perl", new_str: "/usr/my/perl"}
]
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/33f9c3fa-9f38-46c5-8be6-57fce225d389%40googlegroups.
com
<https://groups.google.com/d/msgid/ansible-project/33f9c3fa-9f38-46c5-8be6-57fce225d389%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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/CAPrnkaTO3mixTPBRzJVb9q1A%2Bsk63TwVrMt1hVgSmGKt8vNJaA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.