FAQ
Hi,
I'm currently looking into moving from Puppet to Saltstack and I'm
wondering how to reconstruct the previous hiera based setup we were using
and maybe improving on it. I have a specific example I want to experiment
with and that is the creation of user accounts on multiple nodes.

What I basically want to accomplish is this:
1) define a set of users (core_users) that should be created on all systems
(i.e. '*')
2) on a system "webserver9" I want to apply a set of additional users
(additional_users) on top of the core_users that is I want merge core_users
from the '*' definition and additional_users and apply the result to the
node.
3) on a system "webserver10" I *only* want to apply the additional_users
and *not* the core_users that is the definition of additional_users should
override the definition of core_users for this one node.

Is there a way to express something like this in Saltstack and if so how?

Regards,
   Dennis

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Stephen Spencer at Sep 24, 2014 at 3:47 am
    The easy way:
    Express your defined states as individual salt states that can be assigned
    by whichever combinatio of grains, gathered data, hostsnames, subnets, etc
    that properly describe your systems.

    Moderate challenge til you get a handle on the templating engine (jinja and
    something else are includedmm) :
    Use the built-in logic capabilities within Salt's templating engines to
    define a generic state definition that can take data from a pillar for use
    in the construction of appropriate states.

    -S

    The hard way
    Write a state and/or execution module that allows granular, local user
    account management (actually sounds kinda fun, but not the most immediate
    solution)
    On Sep 23, 2014 7:30 PM, "Dennis Jacobfeuerborn" wrote:

    Hi,
    I'm currently looking into moving from Puppet to Saltstack and I'm
    wondering how to reconstruct the previous hiera based setup we were using
    and maybe improving on it. I have a specific example I want to experiment
    with and that is the creation of user accounts on multiple nodes.

    What I basically want to accomplish is this:
    1) define a set of users (core_users) that should be created on all
    systems (i.e. '*')
    2) on a system "webserver9" I want to apply a set of additional users
    (additional_users) on top of the core_users that is I want merge core_users
    from the '*' definition and additional_users and apply the result to the
    node.
    3) on a system "webserver10" I *only* want to apply the additional_users
    and *not* the core_users that is the definition of additional_users should
    override the definition of core_users for this one node.

    Is there a way to express something like this in Saltstack and if so how?

    Regards,
    Dennis

    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Florian Ermisch at Sep 24, 2014 at 7:11 am
    Hi Dennis,

    I would write a state that gathers the users to create from pillar:

    {% for user in salt['pillar.get']('core_users',[]) + salt['pillar.get']('additional_users',[]) %}
    {{ user }}:
       user.present
    […]

    For the "additional in place of core" part you /could/ use templating inside of pillar to change what the minion actually gets when the top.sls includes, say, users.sls:

    {% if salt['grains.get']('id') not in ['webserver10'] %}
    core_users:
       - mary
       - bill
    {% endif %}

    {% if salt['grains.get']('id') in ['webserver9', 'webserver10' ] %}
       {% if salt['grains.get']('id') in ['webserver9'] %}
    additional_users:
       {% elif salt['grains.get']('id') in ['webserver10'] %}
    core_users:
       {% endif %}
       - joe
    {% endif %}

    But to make it easier to figure out why which minions sees which pillar-data you should differentiate between your minions in your pillar's top.sls. To still keep your users in only two places you can check out what the formulas are doing with map.jinja (so you'll have core_users.jinja and additional_users.jinja).

    Regards, Florian

    PS: I'm not fully awake yet but I hope those are some useful pointers.

    PPS: To keep this a little shorter I just used a list of logins. To add data you probably want to use dictionaries (which are a little harder to merge and iterate over) for your users attributes like real name and stuff.
    On 24. September 2014 05:47:46 MESZ, Stephen Spencer wrote:
    The easy way:
    Express your defined states as individual salt states that can be
    assigned
    by whichever combinatio of grains, gathered data, hostsnames, subnets,
    etc
    that properly describe your systems.

    Moderate challenge til you get a handle on the templating engine (jinja
    and
    something else are includedmm) :
    Use the built-in logic capabilities within Salt's templating engines to
    define a generic state definition that can take data from a pillar for
    use
    in the construction of appropriate states.

    -S

    The hard way
    Write a state and/or execution module that allows granular, local user
    account management (actually sounds kinda fun, but not the most
    immediate
    solution)
    On Sep 23, 2014 7:30 PM, "Dennis Jacobfeuerborn"
    wrote:
    Hi,
    I'm currently looking into moving from Puppet to Saltstack and I'm
    wondering how to reconstruct the previous hiera based setup we were using
    and maybe improving on it. I have a specific example I want to
    experiment
    with and that is the creation of user accounts on multiple nodes.

    What I basically want to accomplish is this:
    1) define a set of users (core_users) that should be created on all
    systems (i.e. '*')
    2) on a system "webserver9" I want to apply a set of additional users
    (additional_users) on top of the core_users that is I want merge
    core_users
    from the '*' definition and additional_users and apply the result to the
    node.
    3) on a system "webserver10" I *only* want to apply the
    additional_users
    and *not* the core_users that is the definition of additional_users should
    override the definition of core_users for this one node.

    Is there a way to express something like this in Saltstack and if so how?
    Regards,
    Dennis

    --
    You received this message because you are subscribed to the Google Groups
    "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google
    Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

    --
    You received this message because you are subscribed to the Google Groups "Salt-users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedSep 24, '14 at 12:30a
activeSep 24, '14 at 7:11a
posts3
users3

People

Translate

site design / logo © 2022 Grokbase