Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawDB task #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions tasks/drawdb.ansible.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
- name: Deploy drawdb from GitHub Fork
become: true

vars:
github_repo: "https://github.com/LIDSOL/drawdb.git"
app_dir: "/app"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

esto corre como root? tal vez sea mejor si utilizas /tmp/app para no tener que crear un directorio nuevo en la raiz del filesystem (/). Que piensas?


tasks:

- name: Install programs
apt:
name: git, nodejs, npm, rsync
state: present
when: ansible_distribution == "Debian"
tags:
- 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has utilizado los tags a la hora de ejecutar el playbook? normalmente los tags son un string que ayuda a filtrar pasos del notebook. Si no los has utilizado, tal vez sea mejor quitarlos


- name: Clone GitHub repo
git:
repo: "{{ github_repo }}"
dest: "{{ app_dir }}"
force: yes
tags:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yo creo que conviene agregar un paso donde se borren estos archivos al final del playbook (asi podemos correrlo varias veces si es necesario). que piensas?

- 2

- name: install dependencies
command: npm install
args:
chdir: "{{ app_dir }}"
tags:
- 3

- name: Build app
command: npm run build
args:
chdir: "{{ app_dir }}"
tags:
- 4

- name: Install Nginx
apt:
name: nginx
state: latest
when: ansible_distribution == "Debian"
tags:
- 5

- name: Enable nginx
service:
name: nginx
enabled: true
state: started
when: ansible_distribution == "Debian"
tags:
- 6

- name: Remove contents of /var/www/html
command: rm -r /var/www/html
tags:
- 7

- name: Copy build files to prod dir
command: cp -r {{ app_dir }}/dist/ /var/www/html
tags:
- 8

- name: Set permissions of /var/www/html
file:
path: /var/www/html
owner: www-data
group: www-data
mode: "0755"
when: ansible_distribution == "Debian"
tags:
- 9

- name: Restart nginx
service:
name: nginx
state: restarted
when: ansible_distribution == "Debian"
tags:
- 10