v0.01
This commit is contained in:
95
tasks/main.yml
Normal file
95
tasks/main.yml
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
- name: "Add nodejs {{ nodejs_version }} repositories"
|
||||
ansible.builtin.shell: "curl -fsSL https://deb.nodesource.com/setup_{{ nodejs_version }} | sudo bash -"
|
||||
become: yes
|
||||
become_flags: -i # Execute config f
|
||||
|
||||
- name: "Install nodejs {{ nodejs_version }}"
|
||||
apt:
|
||||
pkg:
|
||||
- nodejs
|
||||
|
||||
# Setup node+nvm , check latest release at https://github.com/nvm-sh/nvm
|
||||
|
||||
- name: Setup Node
|
||||
become: yes
|
||||
become_flags: -i # Execute config files such as .profile (Ansible uses non-interactive login shells)
|
||||
become_user: "{{ nodejs_user }}"
|
||||
block:
|
||||
- name: Install nvm
|
||||
become: yes
|
||||
become_user: "{{ nodejs_user }}"
|
||||
ansible.builtin.shell: >
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.40.4/install.sh | bash
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "$HOME"
|
||||
creates: "$HOME/.nvm/nvm.sh"
|
||||
|
||||
- name: Install node
|
||||
become: yes
|
||||
become_user: "{{ nodejs_user }}"
|
||||
shell: >
|
||||
. $HOME/.nvm/nvm.sh && nvm install {{ item }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "$HOME"
|
||||
creates: "$HOME/.nvm/versions/{{ item }}"
|
||||
loop:
|
||||
- "{{ nodejs_nvm_version }}"
|
||||
when: nodejs_nvm
|
||||
|
||||
- name: Install PM2 globally
|
||||
npm:
|
||||
name: pm2
|
||||
global: true
|
||||
state: present
|
||||
become: true
|
||||
become_user: "{{ nodejs_user }}"
|
||||
|
||||
- name: Add extras
|
||||
become: yes
|
||||
become_flags: -i # Execute config files such as .profile (Ansible uses non-interactive login shells)
|
||||
become_user: "{{ nodejs_user }}"
|
||||
|
||||
block:
|
||||
- name: Install npm modules
|
||||
become: yes
|
||||
become_user: "{{ nodejs_user }}"
|
||||
ansible.builtin.shell: >
|
||||
npm install {{ item.name }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "$HOME"
|
||||
with_items: "{{ npm_modules }}"
|
||||
when: npm_modules is defined
|
||||
- name: Enable npm modules
|
||||
become: yes
|
||||
become_user: "{{ nodejs_user }}"
|
||||
ansible.builtin.shell: >
|
||||
{{ item.enable }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
chdir: "$HOME"
|
||||
with_items: "{{ npm_modules }}"
|
||||
when: npm_modules.item.enable is true
|
||||
#sudo npm install --global --unsafe-perm puppeteer
|
||||
|
||||
- name: Download and install Composer
|
||||
shell: curl -sS https://getcomposer.org/installer | php
|
||||
args:
|
||||
chdir: /usr/src/
|
||||
creates: /usr/local/bin/composer
|
||||
become: yes
|
||||
when: composer
|
||||
|
||||
- name: Add Composer to global path
|
||||
copy:
|
||||
dest: /usr/local/bin/composer
|
||||
group: root
|
||||
mode: '0755'
|
||||
owner: root
|
||||
src: /usr/src/composer.phar
|
||||
remote_src: yes
|
||||
become: yes
|
||||
when: composer
|
||||
Reference in New Issue
Block a user