Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] apache.clean removed too much files, breaking installation after reinstall #390

Open
danny-smit opened this issue Apr 19, 2024 · 0 comments
Labels

Comments

@danny-smit
Copy link

danny-smit commented Apr 19, 2024

Your setup

Formula commit hash / release tag

v1.2.2

Versions reports (master & minion)

Master:

Salt Version:
          Salt: 3007.0
 
Python Version:
        Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.16.0
      cherrypy: unknown
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.3
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.15.1
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.3.3
           ZMQ: 4.3.4
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist: centos 7.9.2009 Core
        locale: utf-8
       machine: x86_64
       release: 3.10.0-1160.114.2.el7.x86_64
        system: Linux
       version: CentOS Linux 7.9.2009 Core

Minion:

Salt Version:
          Salt: 3007.0
 
Python Version:
        Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.16.0
      cherrypy: 18.8.0
      dateutil: 2.8.2
     docker-py: 7.0.0
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.3
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.15.1
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.3.3
           ZMQ: 4.3.4
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist: debian 12.5 bookworm
        locale: utf-8
       machine: x86_64
       release: 6.1.0-18-amd64
        system: Linux
       version: Debian GNU/Linux 12.5 bookworm

Pillar / config used


Bug details

Describe the bug

When executing "apache.clean" the following actions are performed:

  • Disable the service
  • Remove the installed package
  • Wipe the configuration directory /etc/apache2 or /etc/httpd

On Debian based systems, the package "apache2" is uninstalled, but all module packages remain installed.

When installing apache2 afterwards, only the configuration files of that package are installed, but all module configuration files have been wiped and are not installed. This results to a broken apache installation

Steps to reproduce the bug

$ salt <host> state.apply apache,apache.modules
$ salt <host> state.apply clean
$ salt <host> state.apply apache,apache.modules

The third command breaks with errors like:

          ID: apache-config-modules-ssl-enable        
    Function: cmd.run                                 
        Name: a2enmod -f ssl                          
      Result: False                                   
     Comment: Command "a2enmod -f ssl" run            
     Started: 14:17:49.810351                         
    Duration: 31.092 ms                               
     Changes:                                         
              ----------                              
              pid:                                    
                  292010                              
              retcode:                                
                  1                                   
              stderr:                                 
                  ERROR: Module ssl does not exist!   
              stdout:                                 

Expected behaviour

The third command should successfully install and configure apache, just like the first command did.

Attempts to fix the bug

Additional context

Only a work-around:

$ salt <host> cmd.run "apt purge -y 'apache2*' 'libapache2-mod*' "
$ salt <host> state.apply apache,apache.modules

Alternative work around; implement a custom clean:

{%- from "apache/map.jinja" import apache without context %}

disable_apache:
  service.disabled:
    - name: {{ apache.service.name }}
    - enable: False

uninstall_apache:
  pkg.purged:
    - pkgs:
      - {{ apache.pkg.name }}

This works nicely, it purges the apache2 configuration, but does not touch the module files from other packages

@danny-smit danny-smit added the bug label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant