Modifying RPM configuration after installation

27 views
Skip to first unread message

JD Rosensweig

unread,
Feb 5, 2016, 10:42:00 PM2/5/16
to Ansible Project

As part of my Ansible playbook I down and install an RPM from an internal repository. This RPM comes packaged with a bunch of configuration. For most of my machines I don't need to change this configuration. However for a small subset, defined by an ansible group, I need to modify a few of the configuration fields.


I'm assuming I would need to do something like so:

  1. Wait till my RPM is installed and "running"
  2. Stop the service
  3. Modify the configuration file somehow? Use a when clause to limit it to the group I want to modify.
  4. Restart the service

Or possibly there is a better way to achieve to do this. Can anyone out there suggest how I could achieve my general goal?

Jakov Sosic

unread,
Feb 6, 2016, 8:38:42 PM2/6/16
to ansible...@googlegroups.com
On 02/06/2016 04:05 AM, JD Rosensweig wrote:
> As part of my Ansible playbook I down and install an RPM from an
> internal repository. This RPM comes packaged with a bunch of
> configuration. For most of my machines I don't need to change this
> configuration. However for a small subset, defined by an ansible group,
> I need to modify a few of the configuration fields.
>
>
> I'm assuming I would need to do something like so:
>
> 1. Wait till my RPM is installed and "running"
> 2. Stop the service
> 3. Modify the configuration file somehow? Use a when clause to limit it
> to the group I want to modify.
> 4. Restart the service
>
> Or possibly there is a better way to achieve to do this. Can anyone out
> there suggest how I could achieve my general goal?



1. RPM shouldn't start the service, ever. DEB packages usually do start
them, but rpm has different policies and in any way, starting service
immediately upon installation from packages is imho a bad practice.

So my first advice would be - don't start the service from RPM, start it
from Ansible.

So, your playbook should look like:

- install package
- modify config file(s)
- start service(s)


To modify files only on a subset of servers, you can opt for two approaches:

1. deploy jinja2 templates to all servers, and address difs for subset
through variables


2. deploy static files (or templates - doesn't matter) when some
specific variable is set in your group.



I would prefer the 1st approach, but that really depends on the format
of your config files and type of changes you need to make... Devil is in
the details.

JD Rosensweig

unread,
Feb 10, 2016, 8:57:12 PM2/10/16
to Ansible Project
Thanks Jakov.

   That worked well for me.  It turns out my service was running because my init replacement, runit, automatically starts the service by default.  Once I switched this off and leveraged the templates, this became easy.

Cheers,

JD
Reply all
Reply to author
Forward
0 new messages