0

As per my requirement is is possible that the rpm is same for all server but only one config file change as per the server environment like production,staging,testing or else. i have bundle of config file for all server but i don't want hardcode it in spec file or it is not possible to create different rpm for all server.it is possible to specify name of the config file at time of rpm install on client side.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
meet patel
  • 181
  • 1
  • 2
  • 17

2 Answers2

0

Possibly a repeat of this one so I will copy my answer from there...


I don't think there's a native way; I would do a %post like you had noted.

However, I would do this (similar to something I do with an internal-only package I develop for work):

  1. Three separate files /etc/name.conf-developer, /etc/name.conf-live, etc.
  2. Have all three packages provide a virtual package, e.g. name-config
  3. Have main package require name-config
    • This will make rpm, yum, or whatever require at least one be installed in the same transaction
  4. Have all three packages conflict with each other
  5. Have each config package's %post (and possibly %verify) symlink /etc/name.conf to the proper config
    • This also helps show the user what is happening

Cons:

  1. It's a little hackish
  2. rpm --whatprovides /etc/name.conf will say it is not owned by any package
Community
  • 1
  • 1
Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
0

Aaron's answer is a good way to do it. another option would be to use a bash if statement to run a sed command on your configuration file in the %post section based on the hostname (such as *prod). This would allow you to replace specific variables depending on the environment. Obviously this is a high level example since I don't know what your config setup looks like. Unfortunately this is an example of what a bad package would look like because it will be hard for others to manage down the line. I'd suggest that you move any configuration files out of the RPM, and you start using Salt, Chef, or Puppet as this is the sort of task they were designed to accomplish.

Forrest
  • 1,370
  • 9
  • 20