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¶
Move any files from the user’s home directory and change their ownership
Add a temporary state, for example:
analysis: user.absent: - purge: True
Run the temporary state, for example:
./run.py 'mytarget' state.sls_id analysis kingfisher
Remove the temporary state
Note
The purge option will delete all of the user’s files.
Delete a cron job¶
Change
cron.present
tocron.absent
in the Salt stateDelete the Salt state
Delete a service¶
Stop and disable the service. For example:
./run.py 'mytarget' service.stop myservice
./run.py 'mytarget' service.disable myservice
Delete any configuration files added by the service (for example, under sites-available
and sites-enabled
, for Apache).
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 packages, for example:
./run.py 'mytarget' pkg.purge libapache2-mod-proxy-uwsgi,uwsgi-plugin-python3,uwsgi
./run.py 'mytarget' pkg.autoremove list_only=True
./run.py 'mytarget' 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 uwsgi
ls /etc/uwsgi
find /usr -name '*uwsgi*'
Delete a firewall setting¶
Import the
unset_firewall
macro:{% from 'lib.sls' import unset_firewall %}
Add a temporary macro call, for example:
{{ unset_firewall('PUBLIC_POSTGRESQL') }}
Deploy the relevant server, for example:
./run.py 'mytarget' state.apply
Remove the temporary macro call
Delete an Apache module¶
Add a temporary state, for example:
headers: apache_module.disabled
Run the temporary state, for example:
./run.py 'mytarget' state.sls_id headers core
Remove the temporary state
Delete an htpasswd entry¶
Add a temporary state, for example:
delete-NAME: webutil.user_absent: - htpasswd_file: /etc/apache2/.htpasswd-NAME
Run the temporary state, for example:
./run.py 'mytarget' state.sls_id delete-NAME core
Remove the temporary state
Delete an Apache virtual host¶
Run, for example:
./run.py 'cove' file.remove /etc/apache2/sites-enabled/cove.conf
./run.py 'cove' file.remove /etc/apache2/sites-available/cove.conf
./run.py 'cove' 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¶
See Delete a user.