FAQ
*Here base is: * /data/salt/states
*Project 01 Base:* /data/salt/project01
*Project 02 Base:* /data/salt/project02

file_roots:
   base:
     - /data/salt/states
   project01:
     - /data/salt/project01
   project02:
     - /data/salt/project02


/data

└── salt

     ├── states
<=========== Is it possible to make "base" as centralized stuff?

     │ ├── appserver

     │ │ ├── tomcat

     │ │ │ └── init.sls

     │ │ └── weblogic

     │ │ └── init.sls

     │ ├── common

     │ │ └── init.sls

     │ ├── webserver

     │ │ ├── apache

     │ │ │ └── init.sls

     │ │ ├── lighttpd

     │ │ │ └── init.sls

     │ │ └── nginx

     │ │ └── init.sls

     │ ├── database

     │ │ ├── mariadb

     │ │ │ └── init.sls

     │ │ ├── mysql

     │ │ │ └── init.sls

     │ │ └── oracle

     │ │ └── init.sls

     │ ├── top.sls <======= Is it
possible to include all project (Project01, Project01 , .. Project0n) in
top.sls?

     │ ├── project01-prd.sls <======= Is it
possible to add Project01 Production related minions entry in this file?

     │ ├── project01-ppd.sls <======= Is it
possible to add Project01 Pre-production related minions entry in this
file?

     │ ├── project02-prd.sls <======= Is it
possible to add Project02 Production related minions entry in this file?
├── project02-ppd.sls <======= Is it
possible to add Project02 Pre-production related minions entry in this
file?
     ├── project01

     │ ├── preprod

     │ │ ├── states

     │ │ │ ├── webserver

     │ │ │ │ └── apache

     │ │ │ │ └── init.sls <======= Is
it possible to include it from base state webserver.apache and override Id
declaration/Names declaration and add extra things that project require?

     │ │ │ ├── appserver

     │ │ │ │ └── tomcat

     │ │ │ │ └── init.sls <======= Is
it possible to include it from base state appserver.tomcat and override Id
declaration/Names declaration and add extra things that project require?

     │ │ │ ├── common
└── init.sls
     │ │ │ └── database

     │ │ └── pillar

     │ └── prod

     │ ├── states

     │ │ ├── webserver

     │ │ │ └── apache

     │ │ │ └── init.sls <=======
same as above

     │ │ └── appserver

     │ │ └── tomcat

     │ │ └── init.sls <=======
same as above

     │ └── pillar

     ├── project02

     │ ├── preprod

     │ │ ├── states

     │ │ │ ├── webserver

     │ │ │ │ └── nginx

     │ │ │ │ └── init.sls <=======
same as above

     │ │ │ ├── database

     │ │ │ │ └── mysql

     │ │ │ │ └── init.sls <=======
same as above

     │ │ │ ├── appserver

     │ │ │ │ └── tomcat

     │ │ │ │ └── init.sls <=======
same as above

     │ │ │ ├── common

     │ │ │ └── tools

     │ │ └── pillar

     │ └── prod

     │ ├── states

     │ │ ├── database

     │ │ │ └── mysql

     │ │ │ └── init.sls <=======
same as above

     │ │ ├── tools

     │ │ │ └── init.sls

     │ │ ├── webserver

     │ │ │ └── nginx

     │ │ │ └── init.sls <=======
same as above

     │ │ └── appserver

     │ │ └── tomcat

     │ │ └── init.sls <=======
same as above

     │ └── pillar

     └── Pillar


Here I want to create a base as centralized stuff of software's and
configurations. If project has some extra thing to add in software it will
add or override the salt id/name.

So I was trying the same thing here but seems not working for me, I thing
doing some silly mistake, as I'm newbie to salt.

*Here my base is:*
file_roots:
   base:
     - /data/salt/states
   project01:
     - /data/salt/project01

*vim /data/salt/states/webserver/nginx/init.sls*

# Installing package and service
nginx:
   pkg:
     - installed
   service:
     - running
     - enable: True
     - require:
       - pkg: nginx
     - watch:
       - file: /etc/nginx/conf.d/vhost.conf

# Installing virtual hosts
/etc/nginx/conf.d/vhost.conf:
   file.managed:
     - source: salt://webserver/nginx/files/vhost.conf.j2
     - template: jinja
/etc/nginx/conf.d/proxy_params.conf:
   file.managed:
     - source: salt://webserver/nginx/files/proxy_params.conf

*vim /data/salt/project01/webserver/nginx/init.sls*

include:
   - base: webserver.nginx
extend:
   /etc/nginx/conf.d/vhost.conf:
     file.managed:
       - source: salt://webserver/nginx/files/vhost.conf.j2
       - template: jinja

*vim /data/salt/states/top.sls*
project01:
'apps*.dev.project01*':
- webserver.nginx

Here I want to override/extends "/etc/nginx/conf.d/vhost.conf" salt ID, but
it doesn't take the Jinja file from project01 (
/data/salt/project01/webserver/nginx/files/vhost.conf.j2) .
It takes the file from jinja file from (
/data/salt/states/webserver/nginx/files/vhost.conf.j2), What changes should
  I do so that it will consider Jinja file from project01 (
/data/salt/project01/webserver/nginx/files/vhost.conf.j2) and not the
default one.

*Some more question: *

1) Is it possible to run highstate for project01 only, like "salt '*'
state.highstate --top = project01-ppd.sls"?

2) For one project there are 2 environment running one is Pre-production
and other is production, for that now I have created 2 states
file_roots:
base:
- /data/salt/states
project01-ppd:
- /data/salt/project01-ppd
      project01-prd:
- /data/salt/project01-prd

Here we have written same states for pre-production and production, excepts
few differences like pillar MySQL database user and password, because they
are different in pre-production and production. Is there any way to write
state once for pre-production and production and use pillar values
according to their environment?


Thanks
--Pankaj

--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Pankaj ghadge at Jul 15, 2014 at 7:33 am
    Hi all,

    Please help me out with this, waiting for your responses. As I'm newbie to
    salt, couldn't found any solution after googleing.

    1) As server list goes up salt top.sls become to large and difficult to
    understand, so I thought we can include *.sls file application/project wise
    into top.sls.
    2) I was thinking salt base as centralized repository use it in many
    projects you want, override/add the things if base (centralized repository)
    couldn't solve your purpose, like one application framework php/python
    (django) is used for many projects.
    3) In top.sls, is it possible to include state from base like

    ppd-project01:
       'apps*.dev.project01*':
         - base: webserver.nginx
         - appserver.tomcat

    Please let know I'm thinking in right or wrong direction.

    Thanks
    -- Pankaj

    --
    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 [email protected].
    For more options, visit https://groups.google.com/d/optout.
  • Colton Myers at Jul 18, 2014 at 9:52 pm
    If you want to override the environment for a given salt:// path, you can
    actually use the not-very-well-documented file kwargs feature. If you want
    to get `salt://webserver/nginx/files/vhost.conf.j2` but from a non-default
    environment, try
    `salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01`.
      Keep me posted if that works for you.

    Another problem that you may be running into is that top files are compiled
    cross-environment. So any time you run a highstate, it actually gets the
    top.sls file from each environment and combines it into a single dictionary
    of top data.
    http://docs.saltstack.com/en/latest/ref/states/top.html#how-top-files-are-compiled

    In order to run a single topfile (as requested in your first question in
    your first e-mail) you should use `state.top` and name that topfile
    differently so that you can target it:
    http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.state.html#salt.modules.state.top

    I think that will answer a few of your questions, or at least get you
    started. When you've been through those docs, can you return with any
    additional questions you have?

    --
    Colton Myers

    On Tue, Jul 15, 2014 at 1:33 AM, pankaj ghadge wrote:

    Hi all,

    Please help me out with this, waiting for your responses. As I'm newbie to
    salt, couldn't found any solution after googleing.

    1) As server list goes up salt top.sls become to large and difficult to
    understand, so I thought we can include *.sls file application/project wise
    into top.sls.
    2) I was thinking salt base as centralized repository use it in many
    projects you want, override/add the things if base (centralized repository)
    couldn't solve your purpose, like one application framework php/python
    (django) is used for many projects.
    3) In top.sls, is it possible to include state from base like

    ppd-project01:
    'apps*.dev.project01*':
    - base: webserver.nginx
    - appserver.tomcat

    Please let know I'm thinking in right or wrong direction.

    Thanks
    -- Pankaj

    --
    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 [email protected].
    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 [email protected].
    For more options, visit https://groups.google.com/d/optout.
  • Pankaj ghadge at Jul 21, 2014 at 7:15 am
    Thank you so much for your response.

    1) `salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01` this
    solution worked for me.
    But I'm in the "project01" environment, still here I require to mention "
    saltenv=project01"

    */data/salt/states/top.sls*

    project01:
        'apps*.dev.project01*':
              - webserver.nginx

    */data/salt/project01/webserver/nginx/init.sls*

    include:
       - base: webserver.nginx
    extend:
       /etc/nginx/conf.d/vhost.conf:
         file.managed:
           - source: salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01
               <== Worked for me, but I'm in "project01" environment
           - template: jinja

    2) *top files compiled cross-environment:* This solution solve my issue.
    Thanks for it.

    3) *R**un a single topfile:* Here I will be required to create same copy of
    top.sls and project01-ppd.sls
    As top.sls will be used to combine with other environment while compiling
    and project01-ppd.sls to run a single topfile.

    So am I understood it correctly?.

    On Saturday, 19 July 2014 03:22:34 UTC+5:30, basepi wrote:

    If you want to override the environment for a given salt:// path, you can
    actually use the not-very-well-documented file kwargs feature. If you want
    to get `salt://webserver/nginx/files/vhost.conf.j2` but from a
    non-default environment, try `salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01`.
    Keep me posted if that works for you.

    Another problem that you may be running into is that top files are
    compiled cross-environment. So any time you run a highstate, it actually
    gets the top.sls file from each environment and combines it into a single
    dictionary of top data.
    http://docs.saltstack.com/en/latest/ref/states/top.html#how-top-files-are-compiled

    In order to run a single topfile (as requested in your first question in
    your first e-mail) you should use `state.top` and name that topfile
    differently so that you can target it:
    http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.state.html#salt.modules.state.top

    I think that will answer a few of your questions, or at least get you
    started. When you've been through those docs, can you return with any
    additional questions you have?

    --
    Colton Myers


    On Tue, Jul 15, 2014 at 1:33 AM, pankaj ghadge <[email protected]
    <javascript:>> wrote:
    Hi all,

    Please help me out with this, waiting for your responses. As I'm newbie
    to salt, couldn't found any solution after googleing.

    1) As server list goes up salt top.sls become to large and difficult to
    understand, so I thought we can include *.sls file application/project wise
    into top.sls.
    2) I was thinking salt base as centralized repository use it in many
    projects you want, override/add the things if base (centralized repository)
    couldn't solve your purpose, like one application framework php/python
    (django) is used for many projects.
    3) In top.sls, is it possible to include state from base like

    ppd-project01:
    'apps*.dev.project01*':
    - base: webserver.nginx
    - appserver.tomcat

    Please let know I'm thinking in right or wrong direction.

    Thanks
    -- Pankaj

    --
    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 [email protected] <javascript:>.
    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 [email protected].
    For more options, visit https://groups.google.com/d/optout.
  • Colton Myers at Aug 7, 2014 at 9:20 pm

    1) `salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01` this
    solution worked for me.
    But I'm in the "project01" environment, still here I require to mention "
    saltenv=project01"

    */data/salt/states/top.sls*

    project01:
    'apps*.dev.project01*':
    - webserver.nginx

    */data/salt/project01/webserver/nginx/init.sls*

    include:
    - base: webserver.nginx
    extend:
    /etc/nginx/conf.d/vhost.conf:
    file.managed:
    - source: salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01
    <== Worked for me, but I'm in "project01" environment
    - template: jinja

    Yes, you're in the project01 environment, but you're including/extending a
    state from the base environment, and so you must do the saltenv=project01
    in order to force it to use your project01 environment instead of its base
    environment. Just an idiosyncrasy of cross-environment includes/extends.

    3) *R**un a single topfile:* Here I will be required to create same copy of
    top.sls and project01-ppd.sls
    As top.sls will be used to combine with other environment while
    compiling and project01-ppd.sls to run a single topfile.
    When you do a `state.highstate`, it will combine the top.sls files from all
    your environments. When you do a `state.top` and pass in the name of an
    SLS file that is formatted like a topfile, then it will only target that
    particular top file.

    So for example, you could copy your top.sls to a file called
    my_single_top.sls and then run `salt 'myminion' state.top my_single_top`
    and it would only run the top data inside of my_single_top.sls.

    Does that make sense?

    --
    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 [email protected].
    For more options, visit https://groups.google.com/d/optout.
  • Pankaj ghadge at Aug 8, 2014 at 10:25 am
    Thank you for your support and explaining it to me :)
    On Friday, 8 August 2014 02:50:17 UTC+5:30, basepi wrote:

    1) `salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01` this
    solution worked for me.
    But I'm in the "project01" environment, still here I require to mention "
    saltenv=project01"

    */data/salt/states/top.sls*

    project01:
    'apps*.dev.project01*':
    - webserver.nginx

    */data/salt/project01/webserver/nginx/init.sls*

    include:
    - base: webserver.nginx
    extend:
    /etc/nginx/conf.d/vhost.conf:
    file.managed:
    - source: salt://webserver/nginx/files/vhost.conf.j2?saltenv=project01
    <== Worked for me, but I'm in "project01" environment
    - template: jinja

    Yes, you're in the project01 environment, but you're including/extending
    a state from the base environment, and so you must do the saltenv=project01
    in order to force it to use your project01 environment instead of its base
    environment. Just an idiosyncrasy of cross-environment includes/extends.

    3) *R**un a single topfile:* Here I will be required to create same copy
    of top.sls and project01-ppd.sls
    As top.sls will be used to combine with other environment while
    compiling and project01-ppd.sls to run a single topfile.
    When you do a `state.highstate`, it will combine the top.sls files from
    all your environments. When you do a `state.top` and pass in the name of
    an SLS file that is formatted like a topfile, then it will only target that
    particular top file.

    So for example, you could copy your top.sls to a file called
    my_single_top.sls and then run `salt 'myminion' state.top my_single_top`
    and it would only run the top data inside of my_single_top.sls.

    Does that make sense?
    --
    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 [email protected].
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsalt-users @
postedJul 9, '14 at 10:27a
activeAug 8, '14 at 10:25a
posts6
users2

2 users in discussion

Pankaj ghadge: 4 posts Colton Myers: 2 posts

People

Translate

site design / logo © 2023 Grokbase