Просмотр исходного кода

version to be specified for salt formula

pr/fix/install_formulas_fix
Petr Michalec 7 лет назад
Родитель
Сommit
7a2f1d281c
Аккаунт пользователя с таким Email не найден
6 измененных файлов: 114 добавлений и 5 удалений
  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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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

Загрузка…
Отмена
Сохранить