Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Salt Mine: area of visibility for collected data #44564

Open
Friz-zy opened this issue Nov 16, 2017 · 16 comments
Open

Salt Mine: area of visibility for collected data #44564

Friz-zy opened this issue Nov 16, 2017 · 16 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Milestone

Comments

@Friz-zy
Copy link

Friz-zy commented Nov 16, 2017

Currently all collected data can be fetched by any minion. Because of this Mine feature (and direct Peer Communication too) become unapplicable in setups with untrusted minions like multiple clients on one master or even multiple environments.

For example, ansible collect and share information only between hosts of current execution and any of this hosts and only them can get facts about other hosts. It's very convenient!

With salt currently we should hardcode data into pillar instead of dynamic lookups over group of hosts :(

There is old opened task that can explain typical situation

@gtmanfred
Copy link
Contributor

Why can't publish.publish be used to tie this down and only let certain commands be run?

Daniel

@gtmanfred gtmanfred added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Nov 16, 2017
@gtmanfred gtmanfred added this to the Blocked milestone Nov 16, 2017
@Friz-zy
Copy link
Author

Friz-zy commented Nov 16, 2017

Because when you lock certain of commands, you doesn't lock number of hosts as arguments for this commands. Question not in commands but in virtual groups for minions

Like I have 3 minions, I want share data between 1 &2 but I don't want to let 3 know about 1 and 2 at all

Ansible can do it out of the box for example. With salt currently I should setup separate salt masters for first 2 minions and third one

@gtmanfred
Copy link
Contributor

If the peering system could lock down to what options could be passed, would this solve the problem?

Thanks,
Daniel

@Friz-zy
Copy link
Author

Friz-zy commented Nov 16, 2017

Possibly yes but for me this variant looks like a dirty hack in compare with the splitting Mine data. Because you can configure Mine one time on master and all necessary minions would know facts about other necessary minions by defaut, but with peering system you should additionally execute publish event

Imagine, that I want just populate /etc/hosts with hostname of some group of hosts, not all hosts.
With Salt Mine master config would be like:

mine_functions:
  'hypothetical group of hosts':
    network.ip_addrs:
      interface: eth0
  'another group of hosts': []

Then I can use this code:

{% for server, addrs in salt['mine.get']('hypothetical group of hosts', 'network.ip_addrs') | dictsort() %}
{{ addrs[0] }} {{ server }}
{% endfor %}

for 'hypothetical group of hosts' all should be fine, for 'another group of hosts' just nothing

How to convert it into clear state with peering system?

@gtmanfred
Copy link
Contributor

@saltstack/team-core does anyone have any opinions about this proposal?

Thanks,
Daniel

@gtmanfred gtmanfred added Feature new functionality including changes to functionality and code refactors, etc. and removed Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged labels Nov 16, 2017
@gtmanfred gtmanfred modified the milestones: Blocked, Approved Nov 16, 2017
@yagnik
Copy link
Contributor

yagnik commented Nov 17, 2017

Given that mine_functions can be applied using pillar, can grains be used to lock down where the mine functions run and therefore help you group them, alternatively, we can also add different "names" using grains to support groups of mine functions ?

@Friz-zy
Copy link
Author

Friz-zy commented Nov 17, 2017

Guys, again, main idea it's create groups of minions THAT DON'T KNOW ABOUT OTHER GROUPS!
All your variants - this is situation when minion would public info to all other minions.
Imagine, that people can use one salt master for applying configuration into minions from different clients or different groups of developers with different level of access or knowledge or NDA, whatever...

@stale
Copy link

stale bot commented Mar 12, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Mar 12, 2019
@sathieu
Copy link
Contributor

sathieu commented Mar 13, 2019

I think this bug is still relevant...

@stale
Copy link

stale bot commented Mar 13, 2019

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label Mar 13, 2019
@stale
Copy link

stale bot commented Jan 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Jan 8, 2020
@mchugh19
Copy link
Contributor

mchugh19 commented Jan 9, 2020

Still not stale

@stale
Copy link

stale bot commented Jan 9, 2020

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label Jan 9, 2020
@github-abcde
Copy link
Contributor

Does #55760 sufficiently address some of the concerns raised in this issue?

@Friz-zy
Copy link
Author

Friz-zy commented Jul 18, 2020

Maybe :)
Thank you for mentioning
In short look, this changes just can lock a function to specific minions, prevent other from execution. This is a good security feature, no joks) But it doesn't split the visible areas as I understand.
Correct me if I'm wrong)
Can we split minions into the groups that can use the same function, but this function will return result depend on in which group requested host is located?

@github-abcde
Copy link
Contributor

Minion-side ACL is not about preventing minions from executing specific functions, but it is about preventing other minions (implemented by allowing only specific minions) to get function data from the salt mine:
Any minion can still add any function (and the result from local execution of that function) to the salt mine. However, the big change is that along with the function and its result, a minion can now also specify which other minion(s) are allowed to get that result from the salt mine. If a minion is not allowed, it will receive no result (which is identical behavior as if the data was not present in the mine at all).
As such, if you have a nodegroup of minions, you can use that as a target (https://docs.saltstack.com/en/latest/topics/targeting/nodegroups.html) for which minions are allowed. For example:

salt $minion mine.send eth0_ip_addrs mine_function=network.ip_addrs eth0 allow_tgt='group1' allow_tgt_type=nodegroup

or

salt $minion mine.send eth0_ip_addrs mine_function=network.ip_addrs eth0 allow_tgt='N@group1' allow_tgt_type=compound

would make minion $minion store its eth0 IP address in the salt mine under the alias eth0_ip_addrs, and only allow minions in the nodegroup called group1 to access/retrieve it.
Since mine data is stored per minion (looking at the code in salt/daemons/masterapi.py), another minion can store the same function with a different ACL. However, I have not tested this, so this is purely theoretical for me at this point :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Projects
None yet
Development

No branches or pull requests

6 participants