Lineinfile in v1.1

Hi,

I followed lineinfile for sometime till will we had backrefs, but latest code seems to have changed so wanted to understand

will this still work if i want to comment a line out ?

 lineinfile dest=/tmp/grub.conf state=present regexp='^(splashimage=.*)$' line="#"

with 1.1 you have to

  • add backrefs=True when calling lineifile to activate the backrefs as the default is false.

  • use double \

so your line should become:

lineinfile dest=/tmp/grub.conf backrefs=true state=present regexp='^(splashimage=.*)$' line="#\1"

HTH

​This needs to be added to the docs.

Serge​

Seen that being documented in the module code.

My understanding is the doc is being generated from the code, so it is a matter of refresh

​Ah, I'm too quick, I already have trouble keeping up with the new
features​ that are getting published in the docs :slight_smile:

fully understand ! same for me

not even mentionning that with backrefs I would like to see lineinfile doing the changes for all the matching lines in the target file and not just the latest :slight_smile:

That would be terrific when used in remediation context.

Phil

"not even mentionning that with backrefs I would like to see
lineinfile doing the changes for all the matching lines in the target
file and not just the latest :-)"

At this point, it seems like you should just run sed against the file.

Yeap, considering this at the moment.

as patching lineinfile to replace all matching lines make sense only when using backrefs=True,

and would require significant change to the lineinfile module.

Or just come with a new linesinfile module just for this (note the additional ‘s’ in middle of the name)

thanks

Phil.

The change of code isn’t the concern, but rather the purpose of the module is to make sure a given line is in a file or not.

Thus I think it would be confusing if it did global replacements, as that is not the purpose of the module.

understood and agree

You can find update docs from code at http://docs.ansible.agavee.com/

Docs rebuild run each day

PDF + HTML + ebook will be relase ASAP.

Ok, so absolute requirements for this is it must run from ‘make webdocs’.

It’s not acceptable for them to be hosted on an external site because then they can’t be accessed offline, nor is it easy to contribute to changes to the way the docs are presented.

​Philippe,​

"not even mentionning that with backrefs I would like to see
lineinfile doing the changes for all the matching lines in the target
file and not just the latest :-)"

At this point, it seems like you should just run sed against the file.

​As an excercise I started writing a simple plugin in Bash, here as a
wrapper to "sed -e 's/regexp/replace/':

https://github.com/sergevanginderachter/ansible-modules/blob/f01856c43cfb76bf4cf8e0ac61d02c5091b2ffc4/seds

I tried to write the bash functions as modular as possible. I hope this
might also evolve to a better boilerplate for bash modules :slight_smile:

  Serge
.

Cool !

will have a look an try in the coming days

Phil

It is build from webdocs (make modulejs generate JS required in
angular, code improvement are WIP). Myjenkis build just:

git update
make modulejs
mv docs/js/modules.js $WEBFOLDER

Ok, great, I’ll test shortly.

I would like this to become the default.

I think the next thing to do is probably to make a ‘category’ field in the DOCUMENTATION string such that it can sort or filter by category, and also (if not already to support the EXAMPLES documentation string).

BTW, a pull request to make that part of “make webdocs” seems like a good idea :slight_smile:

Ok, great, I'll test shortly.

Nice!

I would like this to become the default.

Maybe this is not the best solution, web spider do not find data in
page, and don't execute HTML. I'm also working on a HTML page
generation (separate html fragment for each module) to make possibile
ajax crowlong ¹, this is partially working (on my local machine,
sorry) but I need to find some days to refactor Ansible interface
before make it public.

I think the next thing to do is probably to make a 'category' field in the
DOCUMENTATION string such that it can sort or filter by category, and also
(if not already to support the EXAMPLES documentation string).

Add support to EXAMPLES can be easy to add, but I'm not sure if it can
add in UI (parser can just consider all text as code, so have a wrong
impact on page presentation).

Filter by category will add ASAP (when all module have category), in
Issue #2194 I suggest to use "tags" inside "category" to have multiple
tagging capabilities (eg: user, database, mysql) and make possible
have "faceted search" on content... if you are agree i will work on
this feature in the next weeks (category/tag + module tagging).

Now I'm working on coding standard in documentation fragment (as
descrbed in a old mail).

Bye
       Marco

¹ https://developers.google.com/webmasters/ajax-crawling/docs/specification

Tags instead of category seems great, as for examples could we not
just turn a new line into a BR tag?

-- Michael

Tags instead of category seems great, as for examples could we not
just turn a new line into a BR tag?

What? Have all examples without <pre>/<code> tag? Having code without
monospace font I think make docs inusable, have all text with
monospace font mate text less readable. Having not separation in
examples make (in my opinion) documentation a mess of text.

-- Michael

Bye
       Marco