mirror of
https://github.com/kasmtech/ansible
synced 2024-12-05 01:29:24 +00:00
Resolve KASM-1918 "Feature/ uninstall playbook"
This commit is contained in:
parent
fbf8b83c76
commit
148ffb23f5
3 changed files with 110 additions and 1 deletions
22
README.md
22
README.md
|
@ -28,7 +28,7 @@ The steps below for installing Ansible have been tested on CentOS 7.9.2009, Cent
|
|||
`ansible --version`
|
||||
|
||||
## Kasm Multi Server install
|
||||
This project will deploy Kasm Workspaces in a multi-server deployment using Ansible.
|
||||
This playbook will deploy Kasm Workspaces in a multi-server deployment using Ansible.
|
||||
|
||||
* It installs the kasm components on the systems specified in the ansible `inventory` required for the respective roles (db, web, agent).
|
||||
* It creates a new swapfile to ensure that the total swap space matches the size `desired_swap_size` specified on the files in group_vars/.
|
||||
|
@ -60,3 +60,23 @@ It has been tested on CentOS 7.9.2009, CentOS 8.4.2105, Debian 9.13, Debian 10.1
|
|||
4. Login to the deployment as admin@kasm.local using the IP of one of the WebApp servers (eg https://192.168.1.2)
|
||||
|
||||
5. Navigate to the Agents tab, and enable each Agent after it checks in. (May take a few minutes)
|
||||
|
||||
## Kasm Uninstall playbook
|
||||
|
||||
This playbook uninstalls Kasm workspaces from DB, WebApp and Agent servers specified in the `inventory` file.
|
||||
|
||||
It has been tested on CentOS 7.9.2009, CentOS 8.4.2105, Debian 9.13, Debian 10.10, Ubuntu 18.04.5, and Ubuntu 20.04.3
|
||||
|
||||
### Ansible Configuration
|
||||
|
||||
1. Open `inventory` file and fill in the hostnames / ips for the servers that will be fulfilling the agent, webapp and db roles.
|
||||
|
||||
3. Run the deployment.
|
||||
|
||||
`ansible-playbook -Kk -u [username] -i inventory uninstall_kasm.yml`
|
||||
|
||||
Ansible will prompt you for the ssh password and sudo password (will almost always be the same password).
|
||||
|
||||
Or, if you have ssh keys copied over to your servers and have NOPASSWD in sudoers you can just run.
|
||||
|
||||
`ansible-playbook -u [username] -i inventory uninstall_kasm.yml`
|
||||
|
|
83
roles/uninstall/tasks/main.yml
Normal file
83
roles/uninstall/tasks/main.yml
Normal file
|
@ -0,0 +1,83 @@
|
|||
- name: Check for kasm service containers
|
||||
shell: docker ps -f name=kasm_* -q
|
||||
register: service_containers
|
||||
changed_when: false
|
||||
become: true
|
||||
ignore_errors: true
|
||||
|
||||
- name: Remove any kasm service containers
|
||||
shell: "docker rm -f {{ item }}"
|
||||
become: true
|
||||
ignore_errors: true
|
||||
with_items: "{{ service_containers.stdout_lines }}"
|
||||
|
||||
- name: Check for kasm session containers
|
||||
shell: docker container ls -qa --filter=label=kasm.kasmid
|
||||
register: session_containers
|
||||
changed_when: false
|
||||
become: true
|
||||
ignore_errors: true
|
||||
|
||||
- name: Remove any kasm session containers
|
||||
shell: "docker rm -f {{ item }}"
|
||||
ignore_errors: true
|
||||
become: true
|
||||
with_items: "{{ session_containers.stdout_lines }}"
|
||||
|
||||
- name: Check for kasm docker network
|
||||
shell: docker network ls -q -f name=kasm_default_network
|
||||
register: kasm_network
|
||||
become: true
|
||||
ignore_errors: true
|
||||
changed_when: false
|
||||
|
||||
- name: Remove kasm docker network
|
||||
shell: docker network rm kasm_default_network
|
||||
ignore_errors: true
|
||||
become: true
|
||||
when: kasm_network.stdout | length > 0
|
||||
|
||||
- name: Get kasm database docker volume
|
||||
shell: docker volume ls --filter name=kasm_db_* -q
|
||||
ignore_errors: true
|
||||
become: true
|
||||
register: kasm_database
|
||||
changed_when: false
|
||||
|
||||
- name: Remove kasm database docker volume
|
||||
shell: "docker volume rm {{ item }}"
|
||||
ignore_errors: true
|
||||
become: true
|
||||
with_items: "{{ kasm_database.stdout_lines }}"
|
||||
|
||||
- name: Get kasm docker images
|
||||
shell: |
|
||||
docker images --filter "label=com.kasmweb.image=true" -q
|
||||
docker images kasmweb/nginx -q
|
||||
docker images kasmweb/share -q
|
||||
docker images kasmweb/share-private -q
|
||||
docker images kasmweb/agent -q
|
||||
docker images kasmweb/agent-private -q
|
||||
docker images kasmweb/manager -q
|
||||
docker images kasmweb/manager-private -q
|
||||
docker images kasmweb/api -q
|
||||
docker images kasmweb/api-private -q
|
||||
docker images redis -q
|
||||
docker images postgres -q
|
||||
|
||||
register: kasm_images
|
||||
become: true
|
||||
ignore_errors: true
|
||||
changed_when: false
|
||||
|
||||
- name: Remove kasm docker images
|
||||
shell: "docker rmi {{ item }}"
|
||||
become: true
|
||||
ignore_errors: true
|
||||
with_items: "{{ kasm_images.stdout_lines }}"
|
||||
|
||||
- name: Remove kasm install directory
|
||||
file:
|
||||
path: /opt/kasm/
|
||||
state: absent
|
||||
become: true
|
6
uninstall_kasm.yml
Normal file
6
uninstall_kasm.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- hosts:
|
||||
- db
|
||||
- web
|
||||
- agent
|
||||
roles:
|
||||
- uninstall
|
Loading…
Reference in a new issue