Skip to content

setting environment variables with a script before using a state module #41719

@gaetanquentin

Description

@gaetanquentin

Description of Issue/Question

Question or maybe issue:
i want to use states.gem to install a ruby gem, but ruby is part of Software collection package. That means i have to set the environment before calling ruby,. Manually i do it this way:
1: executing the SoftwareCollection (SCL) script to set environment variables: . /opt/rh/rh-ruby23/enable
2. executing the gem command: gem install XXX

I want to do the same with salt. I don't want to use cmd.run since the state controls are not enough. I want to use the state.gem state module but it does not work with SCL even with gem_bin

So how to set environment variables via SCL script to that state.gem can work correctly?

Setup

Salt 2016.11.3

Steps to Reproduce Issue

  1. ruby is installed via software collections and id installed in /opt/rh/rh-ruby23/

A script is provided to set environment variables:
/opt/rh/rh-ruby23/enable

  1. Using this state:
    cfme-gem-xmlsimple:
    gem.installed:
    • user: root
    • name: xml-simple
    • gem_bin: /opt/rh/rh-ruby23/root/usr/bin/gem

won't work since dynamic libraries are not found.

Ideally using a script to set environment variable (in state.environ module?) would be usefull.

Versions Report

Salt 2016.11.5

Salt Version:
Salt: 2016.11.5

Dependency Versions:
cffi: 1.6.0
cherrypy: Not Installed
dateutil: 1.5
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.14
pycrypto: Not Installed
pycryptodome: 3.4.3
pygit2: Not Installed
Python: 2.7.5 (default, Aug 2 2016, 04:20:16)
python-gnupg: Not Installed
PyYAML: 3.10
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Featurenew functionality including changes to functionality and code refactors, etc.P4Priority 4State-Modulestale

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions