[BUG] pkg.installed says it failed to install a package when it did not fail at all...?
Description
I'm using pkg.installed to install the qualys-cloud-agent by Qualys, which uses a local .deb file to install, and the installation appears to work but I am getting the following error in the return regardless.
"Comment: The following packages failed to install/update: qualys"
The daemon appears to be in working order otherwise.
Setup
state file location: /srv/salt/test_local/init.sls
install_qualys:
pkg.installed:
- sources:
- qualys: salt://binaries/qualys/qualys-cloud-agent.x86_64.deb
file location: /srv/salt/binaries/qualys/qualys-cloud-agent.x86_64.deb
Steps to Reproduce the behavior
manual install as a reference:
root@linserv1:/home/user# dpkg --install qualys-cloud-agent.x86_64.deb
Selecting previously unselected package qualys-cloud-agent.
(Reading database ... 142181 files and directories currently installed.)
Preparing to unpack qualys-cloud-agent.x86_64.deb ...
Unpacking qualys-cloud-agent (2.6.0-88) ...
Setting up qualys-cloud-agent (2.6.0-88) ...
Created symlink /etc/systemd/system/multi-user.target.wants/qualys-cloud-agent.service → /lib/systemd/system/qualys-cloud-agent.service.
command to execute: salt linserv1 state.apply test_local
return from linserv1 on first attempt:
linserv1:
----------
ID: install_qualys
Function: pkg.installed
Result: False
Comment: The following packages failed to install/update: qualys
Started: 20:11:42.468825
Duration: 12978.207 ms
Changes:
----------
qualys-cloud-agent:
----------
new:
2.6.0-88
old:
Summary for linserv1
------------
Succeeded: 0 (changed=1)
Failed: 1
------------
Total states run: 1
Total run time: 12.978 s
return from linserv1 if ran again:
linserv1:
----------
ID: install_qualys
Function: pkg.installed
Result: False
Comment: The following packages failed to install/update: qualys
Started: 20:31:36.095354
Duration: 10074.008 ms
Changes:
Summary for linserv1
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 10.074 s
minion debug:
[DEBUG ] Trying to connect to: tcp://192.168.2.10:4506
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test_local/init.sls' using 'jinja' renderer: 0.030831098556518555
[DEBUG ] Rendered data from file: /var/cache/salt/minion/files/base/test_local/init.sls:
install_qualys:
pkg.installed:
- sources:
- qualys: salt://binaries/qualys/qualys-cloud-agent.x86_64.deb
[DEBUG ] Results of YAML rendering:
OrderedDict([('install_qualys', OrderedDict([('pkg.installed', [OrderedDict([('sources', [OrderedDict([('qualys', 'salt://binaries/qualys/qualys-cloud-agent.x86_64.deb')])])])])]))])
[PROFILE ] Time (in seconds) to render '/var/cache/salt/minion/files/base/test_local/init.sls' using 'yaml' renderer: 0.002219676971435547
[DEBUG ] LazyLoaded config.option
[INFO ] Executing command ['systemctl', 'is-active', 'apache2.service'] in directory '/root'
[DEBUG ] stdout: active
[DEBUG ] LazyLoaded pkg.install
[DEBUG ] LazyLoaded pkg.installed
[DEBUG ] Reading configuration from /etc/salt/minion
[DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG ] Including configuration from '/etc/salt/minion.d/beacons.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/beacons.conf
[DEBUG ] Including configuration from '/etc/salt/minion.d/grains.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/grains.conf
[DEBUG ] Including configuration from '/etc/salt/minion.d/mine.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/mine.conf
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: linserv1
[DEBUG ] Could not LazyLoad boto3.assign_funcs: 'boto3.assign_funcs' is not available.
[DEBUG ] Error loading module.boto3_elasticsearch: __init__ failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/salt/loader.py", line 1855, in _load_module
module_init(self.opts)
File "/usr/lib/python3/dist-packages/salt/modules/boto3_elasticsearch.py", line 87, in __init__
__utils__["boto3.assign_funcs"](__name__, "es")
File "/usr/lib/python3/dist-packages/salt/loader.py", line 1354, in __getitem__
func = super().__getitem__(item)
File "/usr/lib/python3/dist-packages/salt/utils/lazy.py", line 108, in __getitem__
raise KeyError(key)
KeyError: 'boto3.assign_funcs'
[DEBUG ] DSC: Only available on Windows systems
[DEBUG ] Module PSGet: Only available on Windows systems
[DEBUG ] Could not LazyLoad pkg.ex_mod_init: 'pkg.ex_mod_init' is not available.
[INFO ] Running state [install_qualys] at time 20:11:42.468824
[INFO ] Executing state pkg.installed for [install_qualys]
[INFO ] Executing command ['dpkg-query', '--showformat', '${Status} ${Package} ${Version} ${Architecture}', '-W'] in directory '/root'
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'linserv1', 'tcp://192.168.2.10:4506', 'aes')
[DEBUG ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'linserv1', 'tcp://192.168.2.10:4506')
[DEBUG ] Connecting the Minion to the Master URI (for the return server): tcp://192.168.2.10:4506
[DEBUG ] Trying to connect to: tcp://192.168.2.10:4506
[DEBUG ] In saltenv 'base', looking at rel_path 'binaries/qualys/qualys-cloud-agent.x86_64.deb' to resolve 'salt://binaries/qualys/qualys-cloud-agent.x86_64.deb'
[DEBUG ] In saltenv 'base', ** considering ** path '/var/cache/salt/minion/files/base/binaries/qualys/qualys-cloud-agent.x86_64.deb' to resolve 'salt://binaries/qualys/qualys-cloud-agent.x86_64.deb'
[INFO ] Executing command ['dpkg', '-I', '/var/cache/salt/minion/files/base/binaries/qualys/qualys-cloud-agent.x86_64.deb'] in directory '/root'
[INFO ] Executing command ['dpkg', '--get-selections', '*'] in directory '/root'
[INFO ] Executing command ['systemd-run', '--scope', '--description', '"salt.loaded_140111172955832.int.module.aptpkg"', 'dpkg', '-i', '--force-confold', '/var/cache/salt/minion/files/base/binaries/qualys/qualys-cloud-agent.x86_64.deb'] in directory '/root'
[INFO ] Executing command ['dpkg-query', '--showformat', '${Status} ${Package} ${Version} ${Architecture}', '-W'] in directory '/root'
[ERROR ] Made the following changes:
'qualys-cloud-agent' changed from 'absent' to '2.6.0-88'
[DEBUG ] Refreshing modules...
[INFO ] Loading fresh modules for state activity
[DEBUG ] LazyLoaded jinja.render
[DEBUG ] LazyLoaded yaml.render
[DEBUG ] LazyLoaded saltutil.refresh_modules
[DEBUG ] LazyLoaded event.fire
[DEBUG ] SaltEvent PUB socket URI: /var/run/salt/minion/minion_event_33e71a0b1f_pub.ipc
[DEBUG ] SaltEvent PULL socket URI: /var/run/salt/minion/minion_event_33e71a0b1f_pull.ipc
[DEBUG ] Sending event: tag = module_refresh; data = {'_stamp': '2020-12-01T20:11:55.435916'}
[DEBUG ] Minion of 'master' is handling event tag 'module_refresh'
[DEBUG ] Refreshing modules. Notify=False
[DEBUG ] Grains refresh requested. Refreshing grains.
[DEBUG ] Reading configuration from /etc/salt/minion
[DEBUG ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG ] Closing IPCMessageClient instance
[INFO ] Completed state [install_qualys] at time 20:11:55.447032 (duration_in_ms=12978.207)
[DEBUG ] File /var/cache/salt/minion/accumulator/140111172775608 does not exist, no need to cleanup
[DEBUG ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG ] Including configuration from '/etc/salt/minion.d/beacons.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/beacons.conf
[DEBUG ] LazyLoaded state.check_result
[DEBUG ] Including configuration from '/etc/salt/minion.d/grains.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/grains.conf
[DEBUG ] Minion return retry timer set to 6 seconds (randomized)
[INFO ] Returning information for job: 20201201201138818336
[DEBUG ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'linserv1', 'tcp://192.168.2.10:4506', 'aes')
[DEBUG ] Including configuration from '/etc/salt/minion.d/mine.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/mine.conf
[DEBUG ] Initializing new AsyncAuth for ('/etc/salt/pki/minion', 'linserv1', 'tcp://192.168.2.10:4506')
[DEBUG ] Connecting the Minion to the Master URI (for the return server): tcp://192.168.2.10:4506
[DEBUG ] Trying to connect to: tcp://192.168.2.10:4506
[DEBUG ] Closing AsyncZeroMQReqChannel instance
[DEBUG ] minion return: {'success': False, 'return': {'pkg_|-install_qualys_|-install_qualys_|-installed': {'name': 'install_qualys', 'changes': {'qualys-cloud-agent': {'old': '', 'new': '2.6.0-88'}}, 'result': False, 'comment': 'The following packages failed to install/update: qualys', '__sls__': 'test_local', '__run_num__': 0, 'start_time': '20:11:42.468825', 'duration': 12978.207, '__id__': 'install_qualys'}}, 'retcode': 2, 'jid': '20201201201138818336', 'fun': 'state.apply', 'fun_args': ['test_local']}
[DEBUG ] Elapsed time getting FQDNs: 0.10596776008605957 seconds
[DEBUG ] Loading static grains from /etc/salt/grains
[DEBUG ] LazyLoaded zfs.is_supported
[DEBUG ] LazyLoaded config.merge
[DEBUG ] LazyLoaded mine.update
[DEBUG ] Subprocess ProcessPayload-Job-20201201201138818336 cleaned up
Expected behavior
But it works tho...
Versions Report
master version:
Salt Version:
Salt: 3002.1
Dependency Versions:
cffi: 1.13.2
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: 2.0.3
gitpython: 2.1.8
Jinja2: 2.10
libgit2: 0.26.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: 2.19
pycrypto: 2.6.1
pycryptodome: 3.4.7
pygit2: 0.26.2
Python: 3.6.9 (default, Oct 8 2020, 12:12:24)
python-gnupg: 0.4.1
PyYAML: 3.12
PyZMQ: 17.1.2
smmap: 2.0.3
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.2.5
System Versions:
dist: ubuntu 18.04 Bionic Beaver
locale: UTF-8
machine: x86_64
release: 4.15.0-123-generic
system: Linux
version: Ubuntu 18.04 Bionic Beaver
minion version:
Salt Version:
Salt: 3002.1
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10
libgit2: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: 3.4.7
pygit2: Not Installed
Python: 3.6.9 (default, Oct 8 2020, 12:12:24)
python-gnupg: 0.4.1
PyYAML: 3.12
PyZMQ: 17.1.2
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.2.5
System Versions:
dist: ubuntu 18.04 Bionic Beaver
locale: UTF-8
machine: x86_64
release: 4.15.0-123-generic
system: Linux
version: Ubuntu 18.04 Bionic Beaver
The key in the sources part responds to the actual package name. Salt is checking after the installation process is finished, whether it's actually installed.
What happens here is you tell Salt to ensure package named qualys is installed. However what is installed is package named qualys-cloud-agent, so state run errors on this.
If you change the state to following, it should work as expected:
install_qualys:
pkg.installed:
- sources:
- qualys-cloud-agent: salt://binaries/qualys/qualys-cloud-agent.x86_64.deb
That fixed it! Wow, so simple but I never would have guessed it.
Thank you!! @lukasraska