-
Notifications
You must be signed in to change notification settings - Fork 219
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
Ansible (Debian-only) #309
Comments
Great idea. It is probably hard to create a role that fits the taste of everyone, but if we don't try, we don't know. I use the following quick-and-dirty role for updating a small deployment. Initial installation would need some more steps, as installing npm, etc. # file: <role_name>/defaults/main.yml
file_transfer_app_user_name: file-transfer # file: <role_name>/tasks/main.yml
- name: create user for file transfer app
register: create_file_transfer_app_user_result
user:
name: "{{ file_transfer_app_user_name }}"
comment: "user for running the file transfer Web app"
group: www-data
- name: reset PsiTransfer sources
register: git_checkout
command: git checkout .
args:
chdir: >-
{{ create_file_transfer_app_user_result.home }}/psitransfer
changed_when: "'Updated 0 paths' not in git_checkout.stderr"
become_user: "{{ file_transfer_app_user_name }}"
- name: update PsiTransfer sources
register: git_pull
command: git pull
args:
chdir: >-
{{ create_file_transfer_app_user_result.home }}/psitransfer
changed_when: "'is up to date' not in git_pull.stdout"
become_user: "{{ file_transfer_app_user_name }}"
- name: build
command: "{{ item.cmd }}"
args:
chdir: "{{ item.dir }}"
with_items:
- cmd: npm install
dir: "{{ create_file_transfer_app_user_result.home }}/psitransfer/app"
- cmd: npm run build
dir: "{{ create_file_transfer_app_user_result.home }}/psitransfer/app"
- cmd: npm install
dir: "{{ create_file_transfer_app_user_result.home }}/psitransfer"
become_user: "{{ file_transfer_app_user_name }}"
when: git_pull.changed
- name: restart file transfer app
service:
name: psitransfer
state: restarted
when: git_pull.changed Could maybe serve as a starting point. |
@lpirl Thanks, that's great, but there is obviously more to it, especially on Debian you need to install node through nodesource. Luckily, I have those things all prepared so it really is just a copy-over. What also need to be part of it is a proxy (such as nginx), and configuration that can be adjusted beforehand. Ansible supports jinja and I went through the pain to setup such things already. Lastly, we need a service to run the app, and systemd is probably the most straight-forward method here when targeting Debian only, for Alpine this would be a different story. But, I just don't like to leverage things like I'm glad that you share your starting point, because it gives me an important thing to answer: How to deploy? When it comes to node projects, I always use Ansible's How do you think about that? Here is how I did this approach with a Deno application: https://github.com/martin-braun/cronmon/blob/master/playbook.yml The |
The "Manual, from source" steps could be incorporated into an Ansible script. I used to do this for Directus deployments and it should be pretty straight forward if we limit ourselves to Debian.
Reasons for this:
Cons for this:
nvm
andnode
don't ship for Debian, but I have a solution for this (nodesource.org), but it makes the Ansible script less portable, hence only Debian would be supported. I might consider Alpine Linux, though.I'm making this issue to see if someone else is interested in this? (You could assign me to this issue right away)
The text was updated successfully, but these errors were encountered: