saltstack-formulas / redis-formula

Redis state
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
40 stars 185 forks source link

db.conf configuration file #64

Open DrDarch opened 7 years ago

DrDarch commented 7 years ago

Hi,

Let me know if this could be usable for a pull request.

I added a generation of the configuration file (/etc/db/db.conf). The file contains a machine IP address, server role (master/slave) etc..., this informations could be used by some administration script (provided by you, for example, which changing roles of master and slave instances, or doing backup etc... ).

The db.conf.jinja:

<redis>
    <user>{{ salt['pillar.get']('redis:dbconf:user', '') }}</user>
    <password>{{ salt['pillar.get']('redis:dbconf:password', '') }}</password>
    <backup>{{ salt['pillar.get']('redis:dbconf:backup', '') }}</backup>
    <master_ip>{{ salt['pillar.get']('redis:dbconf:master_ip', '') }}</master_ip>
    <master_netmask>{{ salt['pillar.get']('redis:dbconf:master_netmask', '') }}</master_netmask>
    <hardwar_ip>{{ salt['pillar.get']('redis:dbconf:hardwar_ip', '') }}</hardwar_ip>
    <hardwar_mask>{{ salt['pillar.get']('redis:dbconf:hardwar_mask', '') }}</hardwar_mask>
    <role>{{ salt['pillar.get']('redis:dbconf:role', '') }}</role>
</redis>

and you can define the variables via pillar:

  dbconf:
    user: admin666
    master_ip: 123.123.123.123

Technically, there are only a few modifications in the original formula code.