siddhartha chakraborty
siddhartha chakraborty

Reputation: 475

Update the config file of minion with the IP Address of one minion

First of all I am pretty new to salt so pardon me if its a trivial question.

I have a salt-master and 3 salt-minions(1 license-minion, 2 app-minion) running in my setup . The requirement have is to update the configuration files in the 2 app-minions with the IP Address of the license-minion.

I know that :

sudo salt 'license-minion' network.ip_addrs

will return the IP Address , but how do I apply it to the app-minions.

Any help will be greatly appreciated.

Upvotes: 0

Views: 733

Answers (1)

seshadri_c
seshadri_c

Reputation: 7340

I think you are looking for Salt Mine. Salt master can retrieve required information from the minions using mine_functions. Other minions can then query this "mine" data. mine_functions can be added in the minion's configuration file or in (minion's) pillar.

Example minion pillar file license-minion.sls:

mine_functions:
  network.ip_addrs:
    - interface: ens192

Pillar refresh, and check if the newly added mine_functions shows up:

salt '*' saltutil.refresh_pillar
salt '*' pillar.items

Now we can get the IP address of the license-minion in app-minion by running the mine.get function from the mine module.

salt 'app-minion1' mine.get license-minion network.ip_addrs

Gives

app-minion1:
    ----------
    license-minion:
        - 1.2.3.4

The same function can be invoked from template files as:

{% set lm_data = salt['mine.get']('license-minion', 'network.ip_addrs') | dictsort() %}

The documentation has some examples on how this information can be used in templates.

Upvotes: 1

Related Questions