diff --git a/.gitignore b/.gitignore index 047d7bb..1479758 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ backup/ +*.tar.gz +*.tar diff --git a/README.md b/README.md index 7447a8e..614e953 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,12 @@ It has been tested on CentOS 7.9.2009, CentOS 8.4.2105, Debian 9.13, Debian 10.1 1. Open `roles/install_common/vars/main.yml`, `group_vars/agent.yml` and update variables if desired. 2. Open `inventory` file and fill in the hostnames / ips for the servers that will be fulfilling the agent, webapp and db roles. + +3. Download the Kasm Workspaces installer from https://www.kasmweb.com/downloads.html and copy it to `roles/install_common/files`. + + Optionally, if doing an offline installation: Download and copy the workspace_images and service_images files to `roles/install_common/files`. -3. Run the deployment. +4. Run the deployment. `ansible-playbook -Kk -u [username] -i inventory install_kasm.yml` @@ -57,9 +61,9 @@ It has been tested on CentOS 7.9.2009, CentOS 8.4.2105, Debian 9.13, Debian 10.1 `ansible-playbook -u [username] -i inventory install_kasm.yml` -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. 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) +6. Navigate to the Agents tab, and enable each Agent after it checks in. (May take a few minutes) ### Adding Additional Agent / Webapp hosts to an existing installation diff --git a/roles/install_common/files/.gitkeep b/roles/install_common/files/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/roles/install_common/tasks/agent_install.yml b/roles/install_common/tasks/agent_install.yml index f7daf7d..28075e3 100644 --- a/roles/install_common/tasks/agent_install.yml +++ b/roles/install_common/tasks/agent_install.yml @@ -9,7 +9,7 @@ delay: 5 - name: Install agent role - command: "bash {{ tempdir.path }}/kasm_release/install.sh -S agent -e -p {{ target_ip }} -m {{ web_ip }} -M {{ manager_token }}" + command: "bash {{ tempdir.path }}/kasm_release/install.sh -S agent -e -p {{ target_ip }} -m {{ web_ip }} -M {{ manager_token }} {{ '-s ' ~ service_images_copy.dest if service_images_file }} {{ '-w ' ~ workspace_images_copy.dest if workspace_images_file }}" register: install_output become: true retries: 20 diff --git a/roles/install_common/tasks/copy_installer.yml b/roles/install_common/tasks/copy_installer.yml new file mode 100644 index 0000000..8c74a55 --- /dev/null +++ b/roles/install_common/tasks/copy_installer.yml @@ -0,0 +1,39 @@ +# List of files in the files directory matching the installer, service_images, and workspace images. +- set_fact: + installer_glob: "{{ lookup('fileglob', '{{role_path}}/files/kasm_workspaces_*.tar.gz', wantlist=True) }}" + service_images_glob: "{{ lookup('fileglob', '{{role_path}}/files/kasm_workspaces_service_images*.tar.gz', wantlist=True) }}" + workspace_images_glob: "{{ lookup('fileglob', '{{role_path}}/files/kasm_workspaces_workspace_images_*.tar.gz', wantlist=True) }}" + delegate_to: localhost + +- set_fact: + # Our installer glob search will also include service_images and workspace_images so we filter them out with difference() + installer_file: "{{ installer_glob | difference(service_images_glob) | difference(workspace_images_glob) | first | default(None) }}" + service_images_file: "{{ service_images_glob | first | default(None) }}" + workspace_images_file: "{{ workspace_images_glob | first | default(None) }}" + +- name: Assert that Kasm installer exists + assert: + that: + - installer_file + fail_msg: + - "Kasm installer not found" + - "Ensure that kasm_workspaces installer tarfile is in {{role_path}}/files/" + +- name: unarchive kasm installer + unarchive: + src: "{{ installer_file }}" + dest: "{{ tempdir.path }}" + +- name: Copy service images + copy: + src: "{{ service_images_file }}" + dest: "{{ tempdir.path }}" + register: service_images_copy + when: service_images_file + +- name: Copy Workspace images + copy: + src: "{{ workspace_images_file }}" + dest: "{{ tempdir.path }}" + register: workspace_images_copy + when: workspace_images_file diff --git a/roles/install_common/tasks/db_install.yml b/roles/install_common/tasks/db_install.yml index 70e339c..79a8430 100644 --- a/roles/install_common/tasks/db_install.yml +++ b/roles/install_common/tasks/db_install.yml @@ -1,5 +1,5 @@ - name: Install database role - command: "bash {{ tempdir.path }}/kasm_release/install.sh -S db -e -Q {{database_password}} -R {{redis_password}} -U {{user_password}} -P {{admin_password}} -M {{manager_token}}" + command: "bash {{ tempdir.path }}/kasm_release/install.sh -S db -e -Q {{database_password}} -R {{redis_password}} -U {{user_password}} -P {{admin_password}} -M {{manager_token}} {{ '-s ' ~ service_images_copy.dest if service_images_file }} {{ '-w ' ~ workspace_images_copy.dest if workspace_images_file }}" register: install_output become: true retries: 20 diff --git a/roles/install_common/tasks/main.yml b/roles/install_common/tasks/main.yml index 4fd9574..ad97645 100644 --- a/roles/install_common/tasks/main.yml +++ b/roles/install_common/tasks/main.yml @@ -58,21 +58,9 @@ name: curl state: present become: true - -- name: Download kasm installer - get_url: - url: "{{ kasm_installer_url }}" - dest: "{{ tempdir.path }}/kasm.tar.gz" - checksum: "{{ kasm_installer_checksum }}" - register: kasm_installer - when: - - not kasm_installed -- name: unarchive kasm installer - unarchive: - remote_src: yes - src: "{{ kasm_installer.dest }}" - dest: "{{ tempdir.path }}" +- include_tasks: + file: copy_installer.yml when: - not kasm_installed @@ -108,6 +96,7 @@ file: path: "{{ tempdir.path }}" state: absent + become: true - name: Print credentials debug: diff --git a/roles/install_common/tasks/web_install.yml b/roles/install_common/tasks/web_install.yml index 388a63b..0d09f37 100644 --- a/roles/install_common/tasks/web_install.yml +++ b/roles/install_common/tasks/web_install.yml @@ -11,7 +11,7 @@ timeout: 60 - name: Install web role - command: "bash {{ tempdir.path }}/kasm_release/install.sh -S app -e -q {{ db_ip }} -Q {{ database_password }} -R {{ redis_password }} -n {{ target_ip }}" + command: "bash {{ tempdir.path }}/kasm_release/install.sh -S app -e -q {{ db_ip }} -Q {{ database_password }} -R {{ redis_password }} -n {{ target_ip }} {{ '-s ' ~ service_images_copy.dest if service_images_file }} {{ '-w ' ~ workspace_images_copy.dest if workspace_images_file }}" register: install_output become: true retries: 20 diff --git a/roles/install_common/vars/main.yml b/roles/install_common/vars/main.yml index 1aa1546..cf83a8f 100644 --- a/roles/install_common/vars/main.yml +++ b/roles/install_common/vars/main.yml @@ -1,6 +1,3 @@ -kasm_installer_url: https://kasm-static-content.s3.amazonaws.com/kasm_release_1.9.0.077388.tar.gz -kasm_installer_checksum: sha256:d925a20ee949ef6a9759587069983eb3a6d56b0532210e74be75894b2a5915ce - # If you want custom passwords change them below, otherwise they will be auto generated and displayed # in a message at the end of the run.