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¶
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¶
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 service, 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-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¶
Add a temporary state, for example:
delete-USER: postgres_user.absent: name: USER
Run the temporary state, for example:
./run.py 'mytarget' state.sls_id delete-USER postgres
Remove the temporary state