xsuchy / rpmconf

Tool to handle rpmnew and rpmsave files
44 stars 19 forks source link

Feature Request: implement unattended mode #45

Closed mstefany closed 3 years ago

mstefany commented 3 years ago

Hello Miroslav,

we have a use case when we would really appreciate if rpmconf could work in "yes to all"/"unattended" mode. Since we manage systems with Puppet anyway, we would run rpmconf -a (via dnf plugin after package installations) to install all .rpmnew files as new configuration files and then Puppet would run anyway and modify configuration files according to our specification.

I have implemented draft patch for rpmconf which introduces -u/--unattended parameter which basically performs as if user would answer each prompt with 'Y' / 'I'. I am not sure if -u is OK, or -U or -y would be better, this is just a proposal.

xsuchy commented 3 years ago

Great! I like this patch.

I am only worried that this solve only one point of view how unattended should work. Other people may want to choose the default answer (and you use non-default option) in handle_rpmnew.

What about --unattended=OPTION,[OPTION] where OPTION can be:

So your case would be --unattended=use_maintainer, but people can also use --unattended=remove_rpmnew,use_rpm_save (which would be technically use_your). This will allows you to make any combination you can image.

What do you think?

mstefany commented 3 years ago

I like the improved version. :)

I am not sure how Python's argparse would handle --unattended=OPTION,[OPTION] approach, and internal checks for valid combinations (what if somebody inputs --unattended=use_rpmnew,remove_rpmnew?) might complicate things as well.

Can we go with simpler --unattended=OPTION and selection from:

Thank you.

xsuchy commented 3 years ago

I was thinking about accepting is as one string and then split(","), but yeah, it may get complicated. I like your compromise.

Will you update this PR or should I?

mstefany commented 3 years ago

I will update the PR and ask you for review.

mstefany commented 3 years ago

Here I implemented proposed behavior: -u/--unattended can now be specified with or without MODE parameter. If no MODE is set, then it behaves as if default was specified. Otherwise use_maintainer, use_your or default can be used.

Debug from new revision:

# rpmconf -d -a -u
rm /etc/dnf/plugins/versionlock.conf.rpmnew
rm /etc/collectd.conf.rpmsave

# rpmconf -d -a -u default
rm /etc/dnf/plugins/versionlock.conf.rpmnew
rm /etc/collectd.conf.rpmsave

# rpmconf -d -a -u use_maintainer
cp --no-dereference /etc/dnf/plugins/versionlock.conf.rpmnew /etc/dnf/plugins/versionlock.conf
rm /etc/collectd.conf.rpmsave

# rpmconf -d -a -u use_your
rm /etc/dnf/plugins/versionlock.conf.rpmnew
cp --no-dereference /etc/collectd.conf.rpmsave /etc/collectd.conf
xsuchy commented 3 years ago

Can you please update the man page too? https://github.com/xsuchy/rpmconf/blob/main/rpmconf.sgml

xsuchy commented 3 years ago

The code looks good. When you update the man page, I am going to merge it.

mstefany commented 3 years ago

Thank you. I added also the manpage stanza - I never wrote one before so I missed which file it was. Now it's there, please check it.

xsuchy commented 3 years ago

Thank you