mirror of
https://github.com/saltstack-formulas/packages-formula.git
synced 2025-04-16 09:40:23 +00:00
Add a conditional to run npms only when explicitely required
This commit is contained in:
parent
df99e1cdcc
commit
9c83969acc
3 changed files with 26 additions and 10 deletions
|
@ -14,7 +14,12 @@ include:
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
### REQ PKGS (without these, some of the WANTED PIPS will fail to install)
|
# As we depend on npm installed, if this state file is invoked every time
|
||||||
|
# if will fail with 'npm not found'. This condition makes sure it's run
|
||||||
|
# only when explicitly asking for adding/removing npms
|
||||||
|
{% if wanted_npms or unwanted_npms %}
|
||||||
|
|
||||||
|
### REQ PKGS (without these, some of the WANTED NPMS will fail to install)
|
||||||
npm_req_pkgs:
|
npm_req_pkgs:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- pkgs: {{ req_pkgs | json }}
|
- pkgs: {{ req_pkgs | json }}
|
||||||
|
@ -66,3 +71,5 @@ wanted_npms:
|
||||||
{{ upn }}:
|
{{ upn }}:
|
||||||
npm.removed
|
npm.removed
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
|
@ -62,10 +62,10 @@ packages:
|
||||||
- goodbye-world
|
- goodbye-world
|
||||||
|
|
||||||
npms:
|
npms:
|
||||||
# dir: /home/kitchen/npms # The target directory in which to install the package, or None for global installation
|
dir: /home/kitchen/npms # The target directory in which to install the package, or None for global installation
|
||||||
# user: kitchen # The user to run NPM with (and to assign to `dir`)
|
user: kitchen # The user to run NPM with (and to assign to `dir`)
|
||||||
# group: kitchen # The group to assign to `dir`
|
group: kitchen # The group to assign to `dir`
|
||||||
# mode: 0755 # The permissions to assign to `dir`
|
mode: 0755 # The permissions to assign to `dir`
|
||||||
# registry: None # The NPM registry from which to install the package
|
# registry: None # The NPM registry from which to install the package
|
||||||
# env: None # A list of environment variables to be set prior to execution
|
# env: None # A list of environment variables to be set prior to execution
|
||||||
# force_reinstall: False # Install the package even if it is already installed
|
# force_reinstall: False # Install the package even if it is already installed
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
## FIXME! inspec's npm resource fails to check correctly (sudo issues, path issues)
|
||||||
|
## so I added some "poor man's checks" to ensure, at least, that npms are in place
|
||||||
|
|
||||||
|
npms_path = '/home/kitchen/npms'
|
||||||
|
|
||||||
wanted_npms = {
|
wanted_npms = {
|
||||||
'hello-world-npm': '1.1.1',
|
'hello-world-npm': '1.1.1',
|
||||||
'sax': '1.2.4',
|
'sax': '1.2.4',
|
||||||
|
@ -13,12 +18,16 @@ control 'Wanted/Required npm packages' do
|
||||||
os.name == 'debian'
|
os.name == 'debian'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe directory(npms_path) do
|
||||||
|
it { should exist }
|
||||||
|
its('owner') { should cmp 'kitchen' }
|
||||||
|
its('group') { should cmp 'kitchen' }
|
||||||
|
its('mode') { should cmp '0755' }
|
||||||
|
end
|
||||||
|
|
||||||
wanted_npms.each do |p,v|
|
wanted_npms.each do |p,v|
|
||||||
describe npm(p) do
|
describe directory("#{npms_path}/node_modules/#{p}") do
|
||||||
it { should be_installed }
|
it { should exist }
|
||||||
# FIXME! Testing for version is failing, seems an issue in inspec
|
|
||||||
# Same happens with testing path, as it performs a cd command and it fails when using sudo
|
|
||||||
# its('version') { should eq v }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue