Not able to execute embedded Saltstack state using gitfs - salt-stack

I am working with the "gitfs" feature of SaltStack in order to execute a state file.
The state file uses the "include" feature to embed other two state files from the repository.
My repository has the following hierarchy:
salt
- dir1
- dir3 / init.sls
- dir4 / init.sls
- dir2
- dir5 / init.sls
My master file is as below:
. . .
fileserver_backend:
- git
gitfs_remotes:
- https://username#bitbucket.org/path/to/repo.git
. . .
The salt/dir1/dir3/init.sls contains the following:
include:
- salt/dir2/dir5/init.sls
- salt/dir1/dir4/init.sls
. . .
On restarting salt-master and then executing
salt-run fileserver.file_list saltenv=base backend=git
shows me all the files from the repository.
But on running
salt '' state.apply salt.dir1.dir3 -l debug
I am getting the following error:
[ERROR ] Data passed to highstate outputter is not a valid highstate return: {'<minion-id>': ['Specified SLS salt/dir2/dir5/init.sls in saltenv base is not available on the salt master or through a configured fileserver', 'Specified SLS salt/dir1/dir4/init.sls in saltenv base is not available on the salt master or through a configured fileserver']}
My system configurations are as follows:
$ salt --versions-report
Salt Version:
Salt: 2016.3.3
Dependency Versions:
cffi: Not Installed
cherrypy: 3.2.2
dateutil: 1.5
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 0.9.1
msgpack-pure: Not Installed
msgpack-python: 0.3.0
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
python-gnupg: Not Installed
PyYAML: 3.10
PyZMQ: 14.0.1
RAET: Not Installed
smmap: 0.8.2
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: Ubuntu 14.04 trusty
machine: x86_64
release: 3.13.0-91-generic
system: Linux
version: Ubuntu 14.04 trusty
The repository gets cached into the "/var/cache/salt/master/gitfs/refs/base/salt" path on restarting salt-master.
But I found "dir2/dir5/init/sls" instead of "dir2/dir5/init.sls"
What could be the reason for this issue?

The issue is most likely in your include declaration. Salt's include module treats SLS files similar to Python modules. For example, you would reference a SLS file foo/bar/baz.sls as foo.bar.baz.
Also, the init.sls file receives special treatment and enables you to treat an entire directory as a module. For example, foo.bar.baz would include either foo/bar/baz.sls or foo/bar/baz/init.sls (depending on which of them actually exists).
In conclusion, your include statement should look like this:
include:
- salt.dir2.dir5
- salt.dir1.dir4

Related

Salt stack: how to set up a package installation check with Chocolate (state)

During the execution of the state, the manager "Chocolate" installs the package RealVNC (Program Files\Real VNC)
Next, I create a key in the registry.
I want the keys to be created only if the VNC installation was successful.
I have tried
Require:
- pkg: realvnc
Watch:
- file: C:\Program Files\Real VNC\vncserver.exe
Both options tell me that the target is not found
Sls
realvncsetup:
chocolatey.installed:
- name: realvnc
reg1:
reg.present:
- name: HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\vncserver
- vname: EnableAnalytics
- vdata: "0"
- vtype: REG_SZ
- watch:
- file: "C:\\Program Files\\RealVNC\\VNC Server"
Error
ID: reg1
Function: reg.present
Name: HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\vncserver
Result: False
Comment: The following requisites were not found:
require:
file: C:\Program Files\RealVNC\VNC Server
Started: 12:39:20.183205
Duration: 0.0 ms
Changes:
salt --versions
Salt Version:
Salt: 3002.1
Dependency Versions:
cffi: 1.12.2
cherrypy: unknown
dateutil: 2.7.3
docker-py: 3.4.1
gitdb: 2.0.5
gitpython: 2.1.11
Jinja2: 2.10
libgit2: 0.27.7
M2Crypto: Not Installed
Mako: 1.0.7
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: 1.3.10
pycparser: 2.19
pycrypto: 2.6.1
pycryptodome: 3.6.1
pygit2: 0.27.4
Python: 3.7.3 (default, Jul 25 2020, 13:03:44)
python-gnupg: 0.4.4
PyYAML: 3.13
PyZMQ: 17.1.2
smmap: 2.0.5
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist: debian 10 buster
locale: UTF-8
machine: x86_64
release: 4.19.0-6-amd64
system: Linux
version: Debian GNU/Linux 10 buster
The requisites that we mention, such as require, watch, etc. should be references to other states that are "scheduled" to run on the targets.
About watch
Even though the path is created by installing the "realvnc" package, there is no Salt state to handle the path. That is why it is showing the error.
Quoting from documentation for watch:
A watch requisite is used to add additional behavior when there are changes in other states.
So if you want to watch on a file, then there should be a state that "handles" the file using the file module.
About require
Also, while specifying require you are referring to pkg module, so Saltstack would look for pkg.installed for realvnc. Whereas you are using chocolatey.installed.
So with below modifications it should work fine.
chocolatey-install-realvnc:
chocolatey.installed:
- name: realvnc
# Use the appropriate path that should exist when realvnc is installed
check-progfiles-path:
file.exists:
- name: 'C:\Program Files\Real VNC\vncserver.exe'
# You can use either or both for require as you see fit
create-registry-entry:
reg.present:
- name: HKEY_LOCAL_MACHINE\SOFTWARE\RealVNC\vncserver
- vname: EnableAnalytics
- vdata: "0"
- vtype: REG_SZ
- require:
- file: 'C:\Program Files\Real VNC\vncserver.exe'
- chocolatey: realvnc

RequestLibrary module not found

I need to use the RequestsLibrary library and when I import it:
*** Settings ***
Library SeleniumLibrary
Library RequestsLibrary
I get an error module not found. When I run pipenv graph I can clearly see it's installed:
(marek) bash-3.2$ pipenv graph
robotframework-requests==0.5.0
- requests [required: Any, installed: 2.22.0]
- certifi [required: >=2017.4.17, installed: 2019.6.16]
- chardet [required: >=3.0.2,<3.1.0, installed: 3.0.4]
- idna [required: >=2.5,<2.9, installed: 2.8]
- urllib3 [required: >=1.21.1,<1.26,!=1.25.1,!=1.25.0, installed: 1.25.3]
- robotframework [required: Any, installed: 3.1.2]
What am I doing wrong ?
As turned out the issue was the fact that I installed the library using pipenv install xyz and that creates brand new virtual environment prior to library installation. So I basically ended up with a virtual environment within virtual environment and Robot couldn't access it. As soon as I got rid off the extra virtual environment, exited out and ran pipenv install robotframework-requests outside of any venv, it ran.

How to set pyenv python for reticulate

I'm using 1.10 version of reticulate package ( R version is 3.5.1) and I want to configure it to use pyenv python (path is /Users/name/.pyenv/versions/hak/bin/python). Running py_config() won't show me this python as available:
python: /usr/bin/python
libpython:
/System/Library/Frameworks/Python.
framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome:
/System/Library/Frameworks/Python.
framework/Versions/2.7:/System/Library
/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/ Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
python versions found:
/usr/bin/python
/usr/local/bin/python
/usr/local/bin/python3
Because my pyenv python isnt available I set RETICULATE_PYTHON env variable on mentioned path. But now i get the error
Error in initialize_python(required_module, use_environment) :
Python shared library
'/Users/name/.pyenv/versions/3.6.5/lib/libpython3.6.dylib'
not found, Python bindings not loaded.
Does anybody know how to solve this ?
pyenv doesn't build pythons with shareable libraries by default. to make sure it does either have the CONFIGURE_OPTIONS variable set or preface your pyenv build $VERSION commands as in the example below:
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.5
see:
https://github.com/pyenv/pyenv/blob/master/plugins/python-build/README.md#building-with---enable-shared)

configure: error: zlib development files not found

I'm trying to install RSEM software. To compile RSEM, I ran "make", then I got the following error:
[configure: error: zlib development files not found
Samtools uses compression routines from the zlib library <http://zlib.net>.
Building samtools requires zlib development files to be installed on the build
machine; you may need to ensure a package such as zlib1g-dev (on Debian or
Ubuntu Linux) or zlib-devel (on RPM-based Linux distributions) is installed.]
Actually, I already installed zlib-devel on my server (Red hat EL 7.4).
[Package zlib-devel-1.2.7-17.el7.x86_64 already installed and latest version]
Can anyone help me figure it out?
Thanks

sbt-1.1.1 sbtVersion showing 1.1.0

I invoke:
brew install sbt
I get:
/usr/local/Cellar/sbt/1.1.1: 491 files, 48.3MB, built in 7 seconds
I invoke:
sbt sbtVersion
I get:
[info] Loading project definition from /Users/name/project
[info] Set current project to name (in build file:/Users/name/)
[info] 1.1.0
I'm expecting to see
[info] 1.1.1
Why don't the version values match?
Thank you.
Most likely, because you have a file project/build.properties with line
sbt.version=1.1.0
So one thing is the version of the launcher that you installed with Homebrew and another is the version of the sbt you launch in particular project. If you don't set it explicitly in project/build.properties, sbt will try to run its own version (launcher's, i.e. 1.1.1 in your case).
Another possible reason is that Homebrew could install the formula, but not link the binaries (assuming you upgraded from sbt 1.1.0). You can run several commands to verify which versions you have
$ brew info sbt
...
$ brew list --versions sbt
sbt 0.13.16 0.13.11 1.0.0 1.0.1 1.1.0 0.13.12 0.13.15 1.1.1 0.13.13 1.0.4 1.0.3 1.0.2
$ brew list sbt
/usr/local/Cellar/sbt/1.1.1/bin/sbt
/usr/local/Cellar/sbt/1.1.1/libexec/bin/ (5 files)
/usr/local/Cellar/sbt/1.1.1/libexec/lib/ (483 files)
You can see here that I have many old versions installed, but the one linked is 1.1.1. In case I need to switch to an older launcher, I can run brew switch sbt 1.0.4, for example.

Resources