diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/defaults/main.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/defaults/main.yml index 54be8fadb0..0c53d36703 100644 --- a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/defaults/main.yml +++ b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/defaults/main.yml @@ -27,9 +27,3 @@ docker_users: [] template_file_name: 'docker-compose.yml' install_dir: '~/appsmith' -# Packer cloud user for AMI and IMAGE -cloud_user: appsmith -cloud_group: appsmith -cloud_directory: '/home/appsmith/appsmith' - -default_user: ubuntu diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/error-checks.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/error-checks.yml new file mode 100644 index 0000000000..db66ffbc9e --- /dev/null +++ b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/error-checks.yml @@ -0,0 +1,11 @@ +- name: Throw error when finding out properly running container + fail: + msg: "Appsmith may already run on this server. Please check out from this address http://{{ansible_host}}" + when: + - container_running.stdout == 'true' + - http_request.status == 200 + +- name: Throw error when existing container not reachable + fail: + msg: "Appsmith may be installed but not work properly. Please check on server (IP: {{ansible_host}})" + when: container_running.stdout == 'true' \ No newline at end of file diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/install-docker.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/install-docker.yml new file mode 100644 index 0000000000..57a2a3db7f --- /dev/null +++ b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/install-docker.yml @@ -0,0 +1,7 @@ +- name: Install Docker + include_tasks: + file: "{{ ansible_distribution }}-setup-docker.yml" + apply: + tags: always + when: "'docker' not in ansible_facts.packages" + tags: always \ No newline at end of file diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/main.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/main.yml index f30df23f0e..badfff084f 100644 --- a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/main.yml +++ b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/main.yml @@ -2,49 +2,13 @@ - name: Gather the package facts package_facts: manager: auto - tags: always -- import_tasks: preflight.yml +- include_tasks: preflight.yml -- name: Throw error when finding out properly running container - fail: - msg: "Appsmith may already run on this server. Please check out from this address http://{{ansible_host}}" - when: - - container_running.stdout == 'true' - - http_request.status == 200 +- include_tasks: error-checks.yml -- name: Throw error when existing container not reachable - fail: - msg: "Appsmith may be installed but not work properly. Please check on server (IP: {{ansible_host}})" - when: container_running.stdout == 'true' - -- name: setup init config - include_tasks: - file: "setup-init-config.yml" - apply: - tags: packer - tags: packer - -- import_tasks: setup-appsmith-runtime.yml - tags: packer - -- import_tasks: cleanup-packer-build.yml - tags: packer - -- name: Install Docker - include_tasks: - file: "{{ ansible_distribution }}-setup-docker.yml" - apply: - tags: always - when: "'docker' not in ansible_facts.packages" - tags: always - -- name: Setup user data AWS AMI - include_tasks: - file: setup-user-data.yml - apply: - tags: packer-aws - tags: packer-aws +- include_tasks: install-docker.yml - import_tasks: start-docker.yml + - import_tasks: setup-appsmith.yml diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-appsmith-runtime.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-appsmith-runtime.yml deleted file mode 100644 index 4b9969bcc8..0000000000 --- a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-appsmith-runtime.yml +++ /dev/null @@ -1,48 +0,0 @@ ---- -- name: create runtime path folder - file: - dest: "{{ cloud_directory }}/scripts" - mode: 0755 - recurse: yes - owner: "{{ cloud_user }}" - group: "{{ cloud_group }}" - state: directory - -- name: create boot script - template: - src: templates/appsmith/scripts/boot.sh - dest: "{{ cloud_directory }}/scripts/boot.sh" - mode: 0755 - -- name: create first-time-setup script - template: - src: templates/appsmith/scripts/first-time-setup.sh - dest: "{{ cloud_directory }}/scripts/first-time-setup.sh" - mode: 0755 - owner: "{{ cloud_user }}" - group: "{{ cloud_group }}" - -- name: create reboot entry job - cron: - name: "appsmith job" - special_time: reboot - user: "{{ cloud_user }}" - job: "{{ cloud_directory }}/scripts/boot.sh" - -- name: setup ssh key for appsmith user - copy: - src: templates/init-ssh.sh - dest: /var/lib/cloud/scripts/per-instance - mode: 0755 - owner: "{{ cloud_user }}" - group: "{{ cloud_group }}" - become: yes - -- name: setup ssh key for {{ default_user }} user - copy: - src: templates/init-ssh.sh - dest: /var/lib/cloud/scripts/per-instance - mode: 0755 - owner: "{{ default_user }}" - group: "{{ cloud_group }}" - become: yes \ No newline at end of file diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-init-config.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-init-config.yml deleted file mode 100644 index e1ea183449..0000000000 --- a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-init-config.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: deploy cloud init config file - template: src=templates/cloud-config.cfg dest=/etc/cloud/cloud.cfg.d/defaults.cfg - become: yes - -- name: create group appsmith - group: name={{ cloud_user }} state=present - become: yes - -- name: create user appsmith - user: name={{ cloud_user }} groups={{ cloud_group }} - become: yes - - -- name: create user {{ default_user }} - user: name={{ default_user }} groups={{ cloud_group }} - become: yes - - -- name: add sudoers group for user {{ cloud_user }} - copy: - content: 'appsmith ALL=(ALL) NOPASSWD: ALL' - dest: /etc/sudoers.d/appsmith - mode: 0440 - owner: root - group: root - become: yes diff --git a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-user-data.yml b/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-user-data.yml deleted file mode 100644 index 374c2f82dd..0000000000 --- a/deploy/ansible/appsmith_playbook/roles/setup-appsmith/tasks/setup-user-data.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: setup runtime user data - copy: - src: ../templates/user-data.sh - dest: /var/lib/cloud/scripts/per-instance - mode: 0755 - owner: "{{ cloud_user }}" - group: "{{ cloud_group }}" - become: yes