From ed0b9b17ca3761e0424a0dca18ae42b1cec7cd26 Mon Sep 17 00:00:00 2001 From: Alexander Maslov Date: Thu, 12 Dec 2019 12:04:11 +0300 Subject: [PATCH] Add purge support --- defaults/main.yml | 5 ++++ tasks/install-server.yml | 4 +-- tasks/main.yml | 16 +++++++++-- tasks/purge.yml | 59 ++++++++++++++++++++++++++++++++++++++++ tasks/python_sni.yml | 11 ++------ vars/main.yml | 18 ++++++++++++ 6 files changed, 99 insertions(+), 14 deletions(-) create mode 100644 tasks/purge.yml diff --git a/defaults/main.yml b/defaults/main.yml index 60a753f..ca510b6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -39,3 +39,8 @@ minio_secret_key: "" # Switches to enable/disable the Minio server and/or Minio client installation. minio_install_server: true minio_install_client: true + +# Purge minio +minio_purge: "no" +minio_purge_python_sni: "yes" +minio_purge_data: "yes" diff --git a/tasks/install-server.yml b/tasks/install-server.yml index 6214efa..e0099c6 100644 --- a/tasks/install-server.yml +++ b/tasks/install-server.yml @@ -65,7 +65,7 @@ - name: Create the Minio server systemd config template: src: minio.service.j2 - dest: "/etc/systemd/system/minio.service" + dest: "{{ minio_service_systemd_path }}" owner: "root" group: "root" when: ansible_service_mgr == "systemd" @@ -76,7 +76,7 @@ - name: Create the Minio server init.d config template: src: minio.init.j2 - dest: "/etc/init.d/minio" + dest: "{{ minio_service_initd_path }}" owner: "root" group: "root" mode: 0750 diff --git a/tasks/main.yml b/tasks/main.yml index f49d6da..f9faea0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,14 +1,24 @@ --- -- name: Add sni support to legacy python installations +- name: "purge minio" + include_tasks: purge.yml + when: minio_purge == "yes" + +- name: "add sni support to legacy python installations" include_tasks: python_sni.yml when: - ansible_os_family == 'Debian' - ansible_python_version is version_compare('2.6.0', '>=') - ansible_python_version is version_compare('2.7.9', '<') + - minio_purge != "yes" - include_tasks: install-server.yml - when: minio_install_server + when: + - minio_install_server + - minio_purge != "yes" - include_tasks: install-client.yml - when: minio_install_client + when: + - minio_install_client + - minio_purge != "yes" + diff --git a/tasks/purge.yml b/tasks/purge.yml new file mode 100644 index 0000000..55bb932 --- /dev/null +++ b/tasks/purge.yml @@ -0,0 +1,59 @@ +--- +- name: "stop minio service" + service: + name: minio + state: stopped + enabled: false + ignore_errors: true + +- name: "remove minio systemd service" + file: + path: "{{ minio_service_systemd_path }}" + state: "absent" + when: ansible_service_mgr == "systemd" + +- name: "remove minio init service" + file: + path: "{{ minio_service_initd_path }}" + state: "absent" + when: ansible_service_mgr != "systemd" + +- name: "remove minio binary" + file: + path: "{{ item }}" + state: "absent" + with_items: + - "{{ minio_server_bin }}" + - "{{ minio_client_bin }}" + +- name: "remove minio user" + user: + name: "{{ minio_user }}" + state: "absent" + +- name: "remove minio group" + group: + name: "{{ minio_group }}" + state: "absent" + +- name: "remove minio python sni support system packages" + package: + name: "{{ item }}" + state: "absent" + with_items: "{{ minio_python_sni_packages }}" + when: minio_purge_python_sni == "yes" + +- name: "remove minio python sni support pip packages" + pip: + name: "{{ item }}" + state: "absent" + with_items: "{{ minio_python_sni_pip_dependencies }}" + ignore_errors: true + when: minio_purge_python_sni == "yes" + +- name: "remove minio data storage directories" + file: + path: "{{ item }}" + state: "absent" + with_items: "{{ minio_server_datadirs }}" + when: minio_purge_data == "yes" diff --git a/tasks/python_sni.yml b/tasks/python_sni.yml index c131e20..e5883af 100644 --- a/tasks/python_sni.yml +++ b/tasks/python_sni.yml @@ -2,11 +2,7 @@ - name: install python-pip and SNI support packages package: - name: - - python-pip - - python-dev - - libssl-dev - - libffi-dev + name: {{ minio_python_sni_packages }} state: present register: _install_python_packages until: _install_python_packages is succeeded @@ -18,10 +14,7 @@ # get_url module in server.yml and client.yml. - name: install the Python SNI python-pip dependencies. pip: - name: - - pyopenssl - - ndg-httpsclient - - pyasn1 + name: {{ minio_python_sni_pip_dependencies }} state: present register: _install_pip_packages until: _install_pip_packages is succeeded diff --git a/vars/main.yml b/vars/main.yml index f1b3a4a..d924e7c 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -7,3 +7,21 @@ go_arch_map: armv6l: 'arm6vl' go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}" + +# Python SNI packages +minio_python_sni_packages: + - python-pip + - python-dev + - libssl-dev + - libffi-dev + +# There extra pip dependencies are needed to add SSL SNI support to +# Python version prior to 2.7.9. +minio_python_sni_pip_dependencies: + - pyopenssl + - ndg-httpsclient + - pyasn1 + +minio_service_systemd_path: "/etc/systemd/system/minio.service" +minio_service_initd_path: "/etc/init.d/minio" +