fix: issue with ansible deployment (#19974)

## Description
Refactored Ansible tasks for installing Appsmith. 
Removed tasks used for Packer builds

Fixes # ([19581](https://github.com/appsmithorg/appsmith/issues/19581))

## Type of change
- Bug fix (non-breaking change which fixes an issue)

## How Has This Been Tested?
- Manual
This commit is contained in:
Sumesh Pradhan 2023-01-25 10:45:04 +05:30 committed by GitHub
parent c41afbc3af
commit f36071b2f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 130 deletions

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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