Skip to content

Commit

Permalink
feat(clean): add cleaning states
Browse files Browse the repository at this point in the history
* libvirt/clean.sls: call all component cleaning state in a sensible
  order.

* libvirt/server/clean.sls: call all server subcomponent cleaning
  state in a sensible order. TLS certificates are not handle for now.

* libvirt/server/config/clean.sls: remove all configuration files.

* libvirt/server/package/clean.sls: remove the libvirt package. The
  dependencies are not managed.

* libvirt/server/service/clean.sls: disable and stop the service.

* libvirt/qemu/clean.sls: remove the qemu package. The dependencies
  are not managed.

* libvirt/extra/clean.sls: remove extra packages. The dependencies are
  not managed.

* libvirt/python/clean.sls: remove the libvirt python library if any.
  The dependencies are not managed.
  • Loading branch information
baby-gnu committed Sep 2, 2019
1 parent 0e735c0 commit dd53de0
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libvirt/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .extra.clean
- .qemu.clean
- .server.clean
- .python.clean
10 changes: 10 additions & 0 deletions libvirt/extra/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import libvirt_settings with context %}
libvirt-extra-clean-pkg-removed:
pkg.removed:
- pkgs: {{ libvirt_settings.extra_pkgs|json }}
16 changes: 16 additions & 0 deletions libvirt/python/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import libvirt_settings with context %}
{%- from tplroot ~ "/python.jinja" import switch_python32 with context %}
{%- set package = switch_python32(libvirt_settings.python3_pkg, libvirt_settings.python2_pkg) %}
{#- Some OS do not have the python3 library #}
{%- if package %}
libvirt-python-clean-pkg-removed:
pkg.removed:
- name: {{ package }}
{%- endif %}
10 changes: 10 additions & 0 deletions libvirt/qemu/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import libvirt_settings with context %}
libvirt-qemu-clean-pkg-removed:
pkg.removed:
- name: {{ libvirt_settings.qemu_pkg }}
7 changes: 7 additions & 0 deletions libvirt/server/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- .service.clean
- .config.clean
- .package.clean
22 changes: 22 additions & 0 deletions libvirt/server/config/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_server_service_clean = tplroot ~ '.server.service.clean' %}
{%- from tplroot ~ "/map.jinja" import libvirt_settings with context %}
include:
- {{ sls_server_service_clean }}
libvirt-server-config-libvirtd-clean-file-absent:
file.absent:
- name: {{ libvirt_settings.libvirtd_config }}
- require:
- sls: {{ sls_server_service_clean }}
libvirt-server-config-daemonconfig-clean-file-absent:
file.absent:
- name: {{ libvirt_settings.daemon_config_path }}/{{ libvirt_settings.libvirt_service }}
- require:
- sls: {{ sls_server_service_clean }}
16 changes: 16 additions & 0 deletions libvirt/server/package/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_clean = tplroot ~ '.server.config.clean' %}
{%- from tplroot ~ "/map.jinja" import libvirt_settings with context %}
include:
- {{ sls_config_clean }}
libvirt-server-package-clean-pkg-removed:
pkg.removed:
- name: {{ libvirt_settings.libvirt_pkg }}
- require:
- sls: {{ sls_config_clean }}
11 changes: 11 additions & 0 deletions libvirt/server/service/clean.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import libvirt_settings with context %}
libvirt-server-service-clean-service-dead:
service.dead:
- name: {{ libvirt_settings.libvirt_service }}
- enable: False

0 comments on commit dd53de0

Please sign in to comment.