Remove Salt configuration

If you delete something from a file, it won’t be removed from the server, in most cases. To remove it, after you deploy:

Delete a file

Run, for example:

./run.py 'docs' file.remove /path/to/file-to-remove

Delete a line from a file

Run, for example:

./run.py 'docs' cmd.run "sed --in-place '/text to match/d' /path/to/file"

Delete a user

  1. Move any files from the user’s home directory and change their ownership

  2. Add a temporary state, for example:

    analysis:
      user.absent:
        - purge: True
    
  3. Run the temporary state, for example:

    ./run.py 'mytarget' state.sls_id analysis kingfisher
    
  4. Remove the temporary state

Note

The purge option will delete all of the user’s files.

Delete a cron job

  1. Change cron.present to cron.absent in the Salt state

  2. Deploy the service

  3. Delete the Salt state

Delete a service

Stop and disable the service.

To stop and disable the icinga2 service on the docs target, for example:

./run.py 'docs' service.stop icinga2
./run.py 'docs' service.disable icinga2

If you deleted the uwsgi service, also run, for example:

./run.py 'cove-ocds' file.remove /etc/uwsgi/apps-available/cove.ini
./run.py 'cove-ocds' file.remove /etc/uwsgi/apps-enabled/cove.ini

Note

There is an open issue to make removing services easier.

Delete a package

Remove a package and its configuration files, and remove any of its dependencies that are no longer needed.

To scrub Icinga-related packages from the docs target, for example:

./run.py 'docs' pkg.purge icinga2,nagios-plugins,nagios-plugins-contrib
./run.py 'docs' pkg.autoremove list_only=True
./run.py 'docs' pkg.autoremove purge=True

Then, login to the server and check for and delete any remaining packages, files or directories relating to the package, for example:

dpkg -l | grep icinga
dpkg -l | grep nagios
ls /etc/icinga2
ls /usr/lib/nagios

Delete a firewall setting

  1. Import the unset_firewall macro:

    {% from 'lib.sls' import unset_firewall %}
    
  2. Add a temporary macro call, for example:

    {{ unset_firewall('PUBLIC_POSTGRESQL') }}
    
  3. Deploy the relevant service, for example:

    ./run.py 'mytarget' state.apply
    
  4. Remove the temporary macro call

Delete an Apache module

  1. Add a temporary state, for example:

    headers:
      apache_module.disabled
    
  2. Run the temporary state, for example:

    ./run.py 'mytarget' state.sls_id headers core
    
  3. Remove the temporary state

Delete an htpasswd entry

  1. Add a temporary state, for example:

    delete-NAME:
      webutil.user_absent:
        - htpasswd_file: /etc/apache2/.htpasswd-NAME
    
  2. Run the temporary state, for example:

    ./run.py 'mytarget' state.sls_id delete-NAME core
    
  3. Remove the temporary state

Delete an Apache virtual host

Run, for example:

./run.py 'cove-ocds' file.remove /etc/apache2/sites-enabled/cove.conf
./run.py 'cove-ocds' file.remove /etc/apache2/sites-available/cove.conf
./run.py 'cove-ocds' file.remove /etc/apache2/sites-available/cove.conf.include

A temporary apache_site.disabled state can be used instead of removing the file in the sites-enabled directory.

Delete an Nginx virtual host

Run, for example:

./run.py 'mytarget' file.remove /etc/nginx/sites-enabled/mysite.conf
./run.py 'mytarget' file.remove /etc/nginx/sites-available/mysite.conf
./run.py 'mytarget' file.remove /etc/nginx/sites-available/mysite.conf.include

Delete a PostgreSQL user

  1. Add a temporary state, for example:

    delete-USER:
      postgres_user.absent:
        name: USER
    
  2. Run the temporary state, for example:

    ./run.py 'mytarget' state.sls_id delete-USER postgres
    
  3. Remove the temporary state