I'm using Ansible to create a backupninja config, which claims to be an INI. I have a default .rdiff file which specifies things like so:
[source]
...
include = /root
include = /home
include = /usr/local
and I want other tasks to add more include directives. So my mysql tasks would add:
include = /var/backups/mysql
to the [source] section.
Unfortunately, if I do:
- ini_file: dest=/etc/backup.d/98.rdiff section=source option=include value=/var/backups/mysql
this trashes all of my other includes.
This isn't a case for lineinfile since the include needs to be in the source section.
I don't see anything about appending an option, just about setting one. And this seems to trash my other include options. What am I missing?
Thanks.
There have been lots of threads about INI file lately, let's
consolidate on one of them
Misread this as "lineinfile", sorry.
It is probably not aware of how to do multiples.
I would strongly recommend the template module.
neither the spec nor most ini file implementations don't allow for
duplicate values. Probably the parser ansible uses doesn't either
(python's ConfigParser IIRC).
INI really doesn't have a spec. But in this case I agree it's weird
and don't think we have to solve it.
http://en.wikipedia.org/wiki/INI_file
Did I mention the template module was really great?
On the subject of ini file parsing...
If you have a hosts entry with a comment following, the ansible parser bombs out with a stack trace.
ie
[example]
my.example.com # this comment makes the parser explode!
Nigel.
Would gladly take patches for this.
Please include the stack trace...
Agreed, it's non-standard and shouldn't be handled by ini_file; I'm just not sure what is INI and what isn't so didn't realize it.
I'm not sure how template could help here because what I have is a file, 99.rdiff, which gets created with stock content on all hosts. What I then want to do is append lines to that file if they don't exist when various plays run, adding their files to the backup locations. Right now I have a hack that assumes that include directives are at the end of the file, which should be fine as long as playbooks are the only things that touch this file, and as long as my current workflow is maintained.
This feels like the assemble module may be very good for you to
generate that file from various plays.
Maybe check that out?