saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

IOError when uninstalling salt via `pkg.remove` #39663

Closed aidanharris closed 6 years ago

aidanharris commented 7 years ago

Description of Issue/Question

I'm using salt to produce a Docker base image for use with Vagrant and would like to create a version without SaltStack pre-installed. If using salt to uninstall salt is not supported then feel free to close this issue.

Steps to Reproduce Issue

salt-call pkg.remove salt
[ERROR   ] Invalid outputter nested specified, fall back to nested
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
IOError: [Errno 2] No such file or directory: '/var/log/salt/minion'
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 379, in salt_call
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 58, in run
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 149, in run
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 91, in display_output
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 38, in try_printout
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 176, in get_printout
  File "/usr/lib64/python2.7/logging/__init__.py", line 1175, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 310, in _log
  File "/usr/lib64/python2.7/logging/__init__.py", line 1268, in _log
    self.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1278, in handle
    self.callHandlers(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1318, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 749, in handle
    self.emit(record)
  File "/usr/lib64/python2.7/logging/handlers.py", line 428, in emit
    self.stream = self._open()
  File "/usr/lib64/python2.7/logging/__init__.py", line 927, in _open
    stream = codecs.open(self.baseFilename, self.mode, self.encoding)
  File "/usr/lib64/python2.7/codecs.py", line 881, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: '/var/log/salt/minion'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 1063, in __global_logging_exception_handler
  File "/usr/lib64/python2.7/logging/__init__.py", line 1175, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 310, in _log
  File "/usr/lib64/python2.7/logging/__init__.py", line 1268, in _log
    self.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1278, in handle
    self.callHandlers(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1318, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 749, in handle
    self.emit(record)
  File "/usr/lib64/python2.7/logging/handlers.py", line 425, in emit
    self.stream.flush()
ValueError: I/O operation on closed file

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 379, in salt_call
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 58, in run
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 149, in run
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 91, in display_output
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 38, in try_printout
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 176, in get_printout
  File "/usr/lib64/python2.7/logging/__init__.py", line 1175, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/log/setup.py", line 310, in _log
  File "/usr/lib64/python2.7/logging/__init__.py", line 1268, in _log
    self.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1278, in handle
    self.callHandlers(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1318, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 749, in handle
    self.emit(record)
  File "/usr/lib64/python2.7/logging/handlers.py", line 428, in emit
    self.stream = self._open()
  File "/usr/lib64/python2.7/logging/__init__.py", line 927, in _open
    stream = codecs.open(self.baseFilename, self.mode, self.encoding)
  File "/usr/lib64/python2.7/codecs.py", line 881, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: '/var/log/salt/minion'
salt-call --log-level=debug pkg.remove salt
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: 1b0d6163fdc2
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Reading configuration from /etc/salt/minion
[INFO    ] Could not determine init system from command line: (/bin/bash)
[DEBUG   ] Please install 'virt-what' to improve results of the 'virtual' grain.
[DEBUG   ] Determining pillar cache
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] compile template: /srv/pillar/top.sls
[DEBUG   ] Jinja search path: ['/srv/pillar']
[PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'jinja' renderer: 0.00177884101868
[DEBUG   ] Rendered data from file: /srv/pillar/top.sls:
base:
  '*':
    - users

[DEBUG   ] LazyLoaded config.get
[DEBUG   ] Results of YAML rendering: 
OrderedDict([('base', OrderedDict([('*', ['users'])]))])
[PROFILE ] Time (in seconds) to render '/srv/pillar/top.sls' using 'yaml' renderer: 0.003741979599
[DEBUG   ] compound_match: 1b0d6163fdc2 ? *
[DEBUG   ] compound_match 1b0d6163fdc2 ? "*" => "True"
[DEBUG   ] compile template: /srv/pillar/users.sls
[DEBUG   ] Jinja search path: ['/srv/pillar']
[PROFILE ] Time (in seconds) to render '/srv/pillar/users.sls' using 'jinja' renderer: 0.000707864761353
[DEBUG   ] Rendered data from file: /srv/pillar/users.sls:
users:
  ## Full list of pillar values
  vagrant:
    fullname: vagrant
    password: vagrant
    enforce_password: True
    # WARNING: If 'empty_password' is set to True, the 'password' statement
    # will be ignored by enabling password-less login for the user.
    empty_password: False
    hash_password: True
    system: False
    home: /home/vagrant
    homedir_owner: vagrant
    homedir_group: vagrant
    createhome: True
    sudouser: True
    # sudo_rules doesn't need the username as a prefix for the rule
    # this is added automatically by the formula.
    # ----------------------------------------------------------------------
    # In case your sudo_rules have a colon please have in mind to not leave
    # spaces around it. For example:
    # ALL=(ALL) NOPASSWD: ALL    <--- THIS WILL NOT WORK (Besides syntax is ok)
    # ALL=(ALL) NOPASSWD:ALL     <--- THIS WILL WORK
    sudo_rules:
      - ALL=(ALL) NOPASSWD:ALL
    sudo_defaults:
      - '!requiretty'
    shell: /bin/bash
    remove_groups: False
    prime_group:
      name: vagrant
      gid: 500
    groups:
      - vagrant
    ssh_auth:
      - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key

[DEBUG   ] Results of YAML rendering: 
OrderedDict([('users', OrderedDict([('vagrant', OrderedDict([('fullname', 'vagrant'), ('password', 'vagrant'), ('enforce_password', True), ('empty_password', False), ('hash_password', True), ('system', False), ('home', '/home/vagrant'), ('homedir_owner', 'vagrant'), ('homedir_group', 'vagrant'), ('createhome', True), ('sudouser', True), ('sudo_rules', ['ALL=(ALL) NOPASSWD:ALL']), ('sudo_defaults', ['!requiretty']), ('shell', '/bin/bash'), ('remove_groups', False), ('prime_group', OrderedDict([('name', 'vagrant'), ('gid', 500)])), ('groups', ['vagrant']), ('ssh_auth', ['ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key'])]))]))])
[PROFILE ] Time (in seconds) to render '/srv/pillar/users.sls' using 'yaml' renderer: 0.00383305549622
[DEBUG   ] LazyLoaded jinja.render
[DEBUG   ] LazyLoaded yaml.render
[DEBUG   ] LazyLoaded pkg.remove
[DEBUG   ] LazyLoaded cmd.run
[INFO    ] Executing command ['rpm', '-qa', '--queryformat', '%{NAME}_|-%{EPOCH}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-(none)\n'] in directory '/root'
[INFO    ] Executing command ['yum', '-y', 'remove', 'salt'] in directory '/root'
[INFO    ] Executing command ['rpm', '-qa', '--queryformat', '%{NAME}_|-%{EPOCH}_|-%{VERSION}_|-%{RELEASE}_|-%{ARCH}_|-(none)\n'] in directory '/root'
[DEBUG   ] Could not LazyLoad nested.output: 'nested.output' is not available.
[ERROR   ] Invalid outputter nested specified, fall back to nested
[DEBUG   ] Could not LazyLoad nested.output: 'nested.output' is not available.
[DEBUG   ] Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 38, in try_printout
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 177, in get_printout
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 978, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1086, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 101, in __getitem__
KeyError: 'nested.output'

[DEBUG   ] Could not LazyLoad nested.output: 'nested.output' is not available.
[ERROR   ] Invalid outputter nested specified, fall back to nested
[DEBUG   ] Could not LazyLoad nested.output: 'nested.output' is not available.
[ERROR   ] Nested output failed: 
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 44, in try_printout
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 177, in get_printout
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 978, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1086, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 101, in __getitem__
KeyError: 'nested.output'
[DEBUG   ] Could not LazyLoad raw.output: 'raw.output' is not available.
[ERROR   ] Invalid outputter raw specified, fall back to nested
[DEBUG   ] Could not LazyLoad nested.output: 'nested.output' is not available.
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
KeyError: 'nested.output'
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 379, in salt_call
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 58, in run
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 149, in run
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 91, in display_output
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 49, in try_printout
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 177, in get_printout
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 978, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1086, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 101, in __getitem__
KeyError: 'nested.output'
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 379, in salt_call
  File "/usr/lib/python2.7/site-packages/salt/cli/call.py", line 58, in run
  File "/usr/lib/python2.7/site-packages/salt/cli/caller.py", line 149, in run
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 91, in display_output
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 49, in try_printout
  File "/usr/lib/python2.7/site-packages/salt/output/__init__.py", line 177, in get_printout
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 978, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1086, in __getitem__
  File "/usr/lib/python2.7/site-packages/salt/utils/lazy.py", line 101, in __getitem__
KeyError: 'nested.output'

Versions Report

salt-call --versions-report
Salt Version:
           Salt: 2016.11.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.5 (default, Nov  6 2016, 00:28:07)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.3.1611 Core
        machine: x86_64
        release: 4.9.11-1-ARCH
         system: Linux
        version: CentOS Linux 7.3.1611 Core
gtmanfred commented 7 years ago

I would highly recommend using the dockerng.sls_build module which does this.

It build the container by putting the salt-thin on the container using put_archive and then it runs your salt-states.tgz using the state.pack module and then deletes itself at the end.

I recently updated it to be able to use the docker.image_present state and wrote a blog post about this here https://blog.gtmanfred.com/docker-and-salt.html

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.