Procházet zdrojové kódy

Merge pull request #46 from salt-formulas/pr/fix/install_formulas_fix

version to be specified for salt formula
fix/force_symlinks
Filip Pytloun před 7 roky
rodič
revize
f68dd4e4be
6 změnil soubory, kde provedl 114 přidání a 5 odebrání
  1. +8
    -2
      .kitchen.yml
  2. +1
    -1
      .travis.yml
  3. +13
    -1
      README.rst
  4. +28
    -1
      salt/master/env.sls
  5. +13
    -0
      tests/integration/master-default/formulas_spec.rb
  6. +51
    -0
      tests/pillar/master_formulas.sls

+ 8
- 2
.kitchen.yml Zobrazit soubor

@@ -15,6 +15,12 @@ provisioner:
formula: salt
grains:
noservices: true
vendor_repo:
- type: apt
url: http://apt-mk.mirantis.com/trusty
key_url: http://apt-mk.mirantis.com/public.gpg
components: salt
distribution: testing
state_top:
base:
"*":
@@ -103,8 +109,8 @@ suites:
- master_ssh_key
- master_ssh_password
- master_ssh_root
- master_handler
- minion_pki_cert
- master_formulas
pillars-from-files:
minion_pki.sls: tests/pillar/minion_pki_ca.sls
minion_pki_cert.sls: tests/pillar/minion_pki_cert.sls
@@ -113,7 +119,7 @@ suites:
master_ssh_key.sls: tests/pillar/master_ssh_minion_key.sls
master_ssh_password.sls: tests/pillar/master_ssh_minion_password.sls
master_ssh_root.sls: tests/pillar/master_ssh_minion_root.sls
master_handler.sls: tests/pillar/master_custom_handler.sls
master_formulas.sls: tests/pillar/master_formulas.sls

- name: control-default
provisioner:

+ 1
- 1
.travis.yml Zobrazit soubor

@@ -27,7 +27,7 @@ before_script:

script:
- test ! -e .kitchen.yml || bundle exec kitchen converge || true
- test ! -e .kitchen.yml || bundle exec kitchen verify
- test ! -e .kitchen.yml || bundle exec kitchen verify -t tests/integration

notifications:
webhooks:

+ 13
- 1
README.rst Zobrazit soubor

@@ -70,9 +70,21 @@ Install formula through system package management
...
environment:
prd:
keysone:
keystone:
source: pkg
name: salt-formula-keystone
nova:
source: pkg
name: salt-formula-keystone
version: 0.1+0~20160818133412.24~1.gbp6e1ebb
postresql:
source: pkg
name: salt-formula-postgresql
version: purged

Formula keystone is installed latest version and the formulas without version are installed in one call to aptpkg module.
If the version attribute is present sls iterates over formulas and take action to install specific version or remove it.
The version attribute may have these values ``[latest|purged|removed|<VERSION>]``.

Clone master branch of keystone formula as local feature branch


+ 28
- 1
salt/master/env.sls Zobrazit soubor

@@ -136,20 +136,47 @@ salt_env_{{ environment_name }}_dirs:
{%- endif %}

{%- set _formula_pkgs = [] %}
{%- set _formula_pkgs_with_version = [] %}
{%- for formula_name, formula in environment.get('formula', {}).iteritems() %}
{%- if formula.source == 'pkg' %}
{%- if formula.version is defined %}
{%- do _formula_pkgs_with_version.append(formula) %}
{%- else %}
{%- do _formula_pkgs.append(formula.name) %}
{%- endif %}
{%- endif %}
{%- endfor %}

{% if _formula_pkgs|length > 1 %}

salt_master_{{ environment_name }}_pkg_formulas:
pkg.latest:
- pkgs:
{%- for pkg in _formula_pkgs %}
- {{ pkg }}
{%- endfor %}
- refresh: True
- cache_valid_time: 300
{% endif %}

{% if _formula_pkgs_with_version|length > 1 %}
{%- for formula in _formula_pkgs_with_version %}
salt_master_{{ environment_name }}_pkg_formula_{{ formula.name }}:
{%- if formula.version == 'latest' %}
pkg.latest:
- refresh: True
- cache_valid_time: 300
{%- elif formula.version == 'purged' %}
pkg.purged:
{%- elif formula.version == 'removed' %}
pkg.removed:
{%- else %}
pkg.installed:
- version: {{ formula.version }}
- refresh: True
- cache_valid_time: 300
{% endif %}
- name: {{ formula.name }}
{%- endfor %}

{% endif %}


+ 13
- 0
tests/integration/master-default/formulas_spec.rb Zobrazit soubor

@@ -0,0 +1,13 @@

%w(keepalived haproxy libvirt ntp openssh).each do |f|
describe package("salt-formula-#{f}") do
it { should be_installed }
end
end

%w(mysql postgresql).each do |f|
describe package("salt-formula-#{f}") do
it { should_not be_installed }
end
end


+ 51
- 0
tests/pillar/master_formulas.sls Zobrazit soubor

@@ -0,0 +1,51 @@
git:
client:
enabled: true
linux:
system:
enabled: true
salt:
master:
enabled: true
pillar:
source:
engine: local
environment:
prd:
formula:
keepalived:
source: pkg
name: salt-formula-keepalived
haproxy:
source: pkg
name: salt-formula-haproxy
libvirt:
source: pkg
name: salt-formula-libvirt
version: latest
ntp:
source: pkg
name: salt-formula-ntp
version: latest
openssh:
source: pkg
name: salt-formula-openssh
version: latest
mysql:
source: pkg
name: salt-formula-mysql
version: purged
postgresql:
source: pkg
name: salt-formula-postgresql
version: removed
dev:
formula:
aptly:
source: git
address: 'https://github.com/salt-formulas/salt-formula-aptly.git'
revision: master
bind:
source: git
address: 'https://github.com/salt-formulas/salt-formula-bind.git'
revision: master

Načítá se…
Zrušit
Uložit