Skip to content

Salt formulas should be considered as a new root #6739

Closed

Description

@kiorky

Today, it is impossible to use a new manually checkouted formula without having to declare it in the master file_roots. The behavior indicated on https://salt.readthedocs.org/en/latest/topics/conventions/formulas.html#adding-a-formula-directory-manually is wrong as it is then more that dropping a directory inside your salt states's root.

To fix that, when we use formulas as a local checkout, the top level directory should be stripped off of the resolution.

eg: if you have /srv/salt/salt-formula/salt/init.sls
Other states can then "include salt" rather having to include "salt-formula.salt"

Evidently, without, the fileserver can not resolve the "salt" directory inside the "formula checkouted directory" when you would have used "include .saltcheckoutdir.salt"
Indeed, it works for gitfs_remote, but it's because the remote is considered as a new root strippening then the offending top directory.

To sum up, I think the behavior with a local checkout of a formula and using it as a gitfs_remote should be the same and local checkouts should be picken up without any further configuration upon the initial checkout.

Related to saltstack-formulas/salt-formula#4
@thatch45 @basepi @AntoineCezar

Activity

  1. stp-ip commented on Aug 16, 2013

    @stp-ip
    Contributor

    The issue came up with the new formula structure and this issue should be considered a bug in my point of view.
    Firstly the documentation is misleading and not complete, but that's besides the point here ^^
    We want to encourage more people to contribute back and cherry picking is not helping there.
    As mentioned above the gitfs_remote already handles it quite well, but having manual submodules or even just checked out formulas doesn't yet work. As the convention is to use *-formula as submodule-folders and repo name, it could be a start to strip the top level directory, when folders within the root are called *-formula. and don't have any .sls files in this directory. Could that be possible?
    Cheers

    @UtahDave

  2. whiteinge commented on Aug 16, 2013

    @whiteinge
    Contributor

    This doesn't directly address the issue but it's related so I'll point it out anyway: You're right that manually cloning a repo and somehow linking or copying it in to file_roots is a crappy workflow. In fact, I'd like to go one step higher than that and say having to manually clone a repo at all is less than ideal. @akoumjian has started work on "spm", a Salt Package Manager, which handles cloning/fetching the repo/package. It's roughly usable now and will likely land in Salt core by next week. There's still a use-case for manually putting stuff in file_roots, of course, but when working with salt-formulas I (personally) would prefer to avoid any manual steps.

  3. akoumjian commented on Aug 16, 2013

    @akoumjian
    Contributor

    Yep, ran into this when first working on SPM. Currently it works (crudely) by grabbing the first root in file_roots['base'] and pillar_roots['base'] and them symlinking the package contents into the appropriate respective folders.

    As an alternative to symlinking, I also considered a way of dynamically adding an SPM specific file_root/pillar_root, but this would require parsing and modifying the user's master config, which I don't like. The second problem with this is that the now there is a separate location where users would have to find formula packages in order to edit the pillar/template files.

  4. modified the milestones: Helium, Hydrogen Release on Feb 4, 2014
  5. modified the milestones: Approved, Helium on Apr 21, 2014
  6. aboe76 commented on Jun 30, 2015

    @aboe76
    Contributor

    @akoumjian I don't see the symlink at the moment am I missing something?

    So far I can do the following:
    spm build /home/aboe/Development/git/zsh-formula/

    which creates /srv/spm/zsh-201506-1.spm

    spm info zsh:

    Name: zsh
    Version: 201506
    Release: 1
    Install Date: Tue, 30 Jun 2015 21:23:38 GMT
    Supported OSes: RedHat, Debian, Suse, Arch
    Supported OS families: RedHat, Debian, Suse, Arch
    Dependencies: None
    OS Dependencies: None
    OS Family Dependencies: None
    Summary: Formula to install zsh
    Description:
    Formula to install zsh
    

    spm files zsh

    /srv/salt/zsh
    /srv/salt/zsh/LICENSE
    /srv/salt/zsh/zsh
    /srv/salt/zsh/zsh/map.jinja
    /srv/salt/zsh/zsh/init.sls
    /srv/salt/zsh/zsh/defaults.yaml
    /srv/salt/zsh/zsh/completions.sls
    /srv/salt/zsh/zsh/grml
    /srv/salt/zsh/zsh/grml/init.sls
    /srv/salt/zsh/zsh/grml/repo.sls
    /srv/pillar/zsh.sls.orig
    /srv/salt/zsh/README.rst
    /srv/salt/zsh/FORMULA
    

    and then installing it:
    spm local install /srv/spm/zsh-201506-1.spm
    Installing package from file /srv/spm/zsh-201506-1.spm
    Proceed? [N/y] y
    ... installing

    /srv/salt/ # tree zsh

    zsh
    ├── FORMULA
    ├── LICENSE
    ├── README.rst
    └── zsh
        ├── completions.sls
        ├── defaults.yaml
        ├── grml
        │   ├── init.sls
        │   └── repo.sls
        ├── init.sls
        └── map.jinja
    

    shouldn't it be:

    /srv/salt # tree zsh 
    zsh
    ├── completions.sls
    ├── defaults.yaml
    ├── grml
    │   ├── init.sls
    │   └── repo.sls
    ├── init.sls
    └── map.jinja
    

    But than again you will be missing the README.rst and LICENSE file...

  7. akoumjian commented on Jul 1, 2015

    @akoumjian
    Contributor

    I believe this is not my version of spm, tech hat did a rewrite and that is
    the one in the pr
    On Tue, Jun 30, 2015 at 14:40 Niels Abspoel [email protected]
    wrote:

    @akoumjian https://github.com/akoumjian I don't see the symlink at the
    moment am I missing something?

    So far I can do the following:
    spm build /home/aboe/Development/git/zsh-formula/

    which creates /srv/spm/zsh-201506-1.spm

    spm info zsh:

    Name: zsh
    Version: 201506
    Release: 1
    Install Date: Tue, 30 Jun 2015 21:23:38 GMT
    Supported OSes: RedHat, Debian, Suse, Arch
    Supported OS families: RedHat, Debian, Suse, Arch
    Dependencies: None
    OS Dependencies: None
    OS Family Dependencies: None
    Summary: Formula to install zsh
    Description:
    Formula to install zsh

    spm files zsh

    /srv/salt/zsh
    /srv/salt/zsh/LICENSE
    /srv/salt/zsh/zsh
    /srv/salt/zsh/zsh/map.jinja
    /srv/salt/zsh/zsh/init.sls
    /srv/salt/zsh/zsh/defaults.yaml
    /srv/salt/zsh/zsh/completions.sls
    /srv/salt/zsh/zsh/grml
    /srv/salt/zsh/zsh/grml/init.sls
    /srv/salt/zsh/zsh/grml/repo.sls
    /srv/pillar/zsh.sls.orig
    /srv/salt/zsh/README.rst
    /srv/salt/zsh/FORMULA

    and then installing it:
    spm local install /srv/spm/zsh-201506-1.spm
    Installing package from file /srv/spm/zsh-201506-1.spm
    Proceed? [N/y] y
    ... installing

    /srv/salt/ # tree zsh

    zsh
    ├── FORMULA
    ├── LICENSE
    ├── README.rst
    └── zsh
    ├── completions.sls
    ├── defaults.yaml
    ├── grml
    │ ├── init.sls
    │ └── repo.sls
    ├── init.sls
    └── map.jinja

    shouldn't it be:

    /srv/salt # tree zsh
    zsh
    ├── completions.sls
    ├── defaults.yaml
    ├── grml
    │ ├── init.sls
    │ └── repo.sls
    ├── init.sls
    └── map.jinja

    But than again you will be missing the README.rst and LICENSE file...

    —
    Reply to this email directly or view it on GitHub
    #6739 (comment).

  8. techhat commented on Jul 1, 2015

    @techhat
    Contributor

    Yes, this is a complete rewrite.

  9. aboe76 commented on Jul 1, 2015

    @aboe76
    Contributor

    @techhat any Idea on how to tackle this, I would like to see spm install a package that is readily available to use in top.sls referencing the package name zsh instead of zsh.zsh.

    samething with the naming convention spm package zsh, while it is realy zsh-formula on gitfs?

  10. xlotlu commented on Jun 9, 2016

    @xlotlu

    How about supporting wildcards? This feels straightforward and natural:

    file_roots:
      base:
        - /srv/salt
        - /srv/salt_formulas/*
    
  11. lorengordon commented on Jun 10, 2016

    @lorengordon
    Contributor

    @xlotlu, the wildcard approach doesn't solve the problem that kiorky mentioned in the OP of how to reference the state...

    Give this file_roots definition:

    file_roots:
      base:
        - /srv/salt
        - /srv/salt_formulas/*
    

    And this folder structure:

    /srv/salt
    /srv/salt_formulas/mysql-formula/mysql/init.sls
    /srv/salt_formulas/php-formula/php/init.sls
    

    The resulting state references would be mysql-formula.mysql and php-formula.php. The desired state references are just mysql and php.

  12. xlotlu commented on Jun 10, 2016

    @xlotlu

    @lorengordon excuse me if I'm missing something obvious. Given your directory structure, the state references you describe would result only if there wasn't a wildcard:

    file_roots:
      base:
        - /srv/salt
        - /srv/salt_formulas
    

    With a wildcard, the internal representation after parsing the glob would be just as if one defined:

    file_roots:
      base:
        - /srv/salt
        - /srv/salt_formulas/mysql-formula
        - /srv/salt_formulas/php-formula
    

    making the mysql and php states accessible directly as desired.

  13. lorengordon commented on Jun 10, 2016

    @lorengordon
    Contributor

    @xlotlu, ahh, no, I'm the one missing the obvious. That implementation is perfectly clear when explained with the example like that.

  14. ghostsquad commented on Dec 29, 2016

    @ghostsquad
  15. stale commented on Aug 11, 2018

    @stale

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Featurestale

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions