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

How to use/depend on this formula #34

Open
bradenwright opened this issue Aug 8, 2017 · 6 comments
Open

How to use/depend on this formula #34

bradenwright opened this issue Aug 8, 2017 · 6 comments

Comments

@bradenwright
Copy link

I was able to successfully use this repo with .kitchen.yml:

cat .kitchen.yml
---
driver:
  name: docker
  use_sudo: false
  privileged: true

verifier:
  name: inspec
  format: doc

provisioner:
  name: salt_solo
  require_chef: false
  formula: sh-jenkins
  is_file_root: true
  cpu: 1024
  memory: 2G
  forward:
  - 8081:8080
  dependencies:
    - name: java
      repo: git
      source: https://github.com/tcpcloud/salt-formula-java
    - name: jenkins
      repo: git
      source: https://github.com/salt-formulas/salt-formula-jenkins
    - name: linux
      repo: git
      source: https://github.com/salt-formulas/salt-formula-linux

platforms:
  - name: ubuntu-16.04
    driver_config:
      provision_command:
        - apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8 && apt-get install -y git
      run_command: /sbin/init
      privileged: true
      pid_one_command: /usr/lib/systemd/systemd

suites:
  - name: sh_jenkins_master
    provisioner:
      state_top:
        base:
          '*':
            - sh-jenkins
      pillars:
        top.sls:
          base:
            '*':
              - sh-jenkins
        sh-jenkins.sls:
          jenkins:
            master:
              enabled: true
              mode: EXCLUSIVE
              # Do not manage config.xml from Salt, use UI instead
              no_config: true
              http:
                network: any
                port: 8080
                protocol: http
              user:
                admin:
                  password: password
                  email: [email protected]
              plugins:
                - name: slack
                - name: rebuild
          linux:
            system:
              enabled: true
              repo:
                jenkins:
                  enabled: true
                  source: "deb http://pkg.jenkins.io/debian-stable binary/"
                  key_url: "https://pkg.jenkins.io/debian/jenkins-ci.org.key"
          java:
            environment:
              enabled: true
              version: '8'
              platform: openjdk
              development: true

Since the dependencies is using a git repo for https://github.com/salt-formulas/salt-formula-jenkins everything seems to work. When I looked up how to use dependencies on salt master I came across:

https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html

which says "We strongly recommend forking a formula repository into your own GitHub account to avoid unexpected changes to your infrastructure." I tried to clone that down into my own folder structure but I can't get things to work... b/c everything is in a sub-directory so I had to change formulas to include 'jenkins.jenkins.master', this hack got me most the way but it can't leverage the module: https://github.com/salt-formulas/salt-formula-jenkins/blob/master/_modules/jenkins_common.py#L140

This is causing pillar data for encrypted password to not be set and formula blows up.

Can someone point me in the right direction for salt best practice on config/how to clone public repos down and leverage them in my own custom Salt formulas.

I know this isn't necessarily an issue with this repo, but hoping I can get some guidance.

Thanks in advance for any help

@bradenwright
Copy link
Author

bradenwright commented Aug 8, 2017

Forgot to add, I have tried to follow: https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#adding-a-formula-directory-manually

git clone to setup:

$ ls /srv/salt-public-formulas/
salt-formula-java  salt-formula-jenkins  salt-formula-linux
file_roots:
  base:
    - /srv/salt/
    - /srv/salt-public-formulas/salt-formula-java
    - /srv/salt-public-formulas/salt-formula-jenkins
    - /srv/salt-public-formulas/salt-formula-linux

and restart salt master. Still getting the following error:

----------
          ID: /var/lib/jenkins/users/admin/config.xml
    Function: file.managed
      Result: False
     Comment: Unable to manage file: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'jenkins_common.encode_password'
     Started: 23:36:17.034939
    Duration: 186.838 ms
     Changes:   
----------

which (as mentioned above) seems to be b/c it can't access https://github.com/salt-formulas/salt-formula-jenkins/blob/master/_modules/jenkins_common.py#L140

@bradenwright
Copy link
Author

Anyone, ideas?

@fpytloun
Copy link
Member

Hello,

you can use these scripts to bootstrap salt master and install formulas:
https://github.com/salt-formulas/salt-formulas/tree/master/deploy/scripts

These scripts supports both package-based and git-based installation.

@bradenwright
Copy link
Author

Thank you kindly, I'll check that out.

Really I would prefer use git, but it doesn't seem like projects are good about bumping versions. Also I was doing researching I can across:

"We strongly recommend forking a formula repository"
https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html

Which was pretty shocking, I consider that an Anti-Pattern! Which probably mainly exists b/c of improper versioning. B/c of this I was going to follow their recommendation of forking (or cloning) even though doing so pains me.

@dalvizu
Copy link
Contributor

dalvizu commented Jan 15, 2018

It isn't documented in kitchen-salt, but you can just add a branch and name a commit or a tag and still use the public repo.

Agree this is an anti-pattern - I'm still new to salt but formula dependency management is not a strong suite, they have no equivalent of puppet's librarian that i'm aware of (http://librarian-puppet.com/).

SPM seems to be upcoming? https://docs.saltstack.com/en/latest/topics/spm/

@fpytloun
Copy link
Member

SPM could be an option one day. For production use, we are building debian packages: https://launchpad.net/~salt-formulas/+archive/ubuntu/ppa
For development, etc. there's git clone, eventually to some specific tag or commit hash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants