On 12/07/2013 10:28 AM, Michael Scherer wrote:
Le vendredi 06 décembre 2013 à 18:01 +0100, Miroslav Suchy a écrit :
> >Working on Copr, I want to replace/add one line in file. I spent more
> >then hour trying various things, but I'm out of ideas.
> >
> >What I'm trying to do is:
> >
> >self.conn.module_name = "lineinfile"
> >self.conn.module_args = "dest=/etc/mock/%s.cfg
> >line=\"config_opts['chroot_setup_cmd'] = 'install @build
%s'\"
> >regexp=\"^.*chroot_setup_cmd.*$\"" % (self.chroot,
self.buildroot_pkgs)
> >
> >Which in yaml language should be (with placeholders expanded):
> >
> >- name: putting scl-utils-build into minimal buildroot of fedora-19-i386
> > lineinfile:
> > dest=/etc/mock/fedora-19-i386.cfg
> > line="config_opts['chroot_setup_cmd'] = 'install @build
> >scl-utils-build'"
> > regexp="^.*chroot_setup_cmd.*$"
> >
> >I tried several things - among all:
> > - change regexp
> > - do not use regexp at all as that should put $line at the end of
> >file, which would work as well
> > - use command module with sed, but there is too much of escaping and
> >it is unreadable
> >
> >Can somebody advise me what should be correct form to replace or add
> >that line to mock config please?
I tested the following playbook, and it work. So I think we may need
more information on what you try and how.
I found it.
For the record: It was permission problem. The connection was made as copr user and not as
root user. And copr user
obviously can't modify /etc/mock/* files.
--
Miroslav Suchy, RHCE, RHCDS
Red Hat, Software Engineer, #brno, #devexp, #fedora-buildsys