Files
configs/playbooks/roles/software_nvm/tasks/main.yml
2024-10-08 21:41:38 +02:00

57 lines
1.2 KiB
YAML

---
- name: Install dependencies
ansible.builtin.package:
name:
- git
- name: Clone nvm
tags:
- install
become_user: "{{ username }}"
become: true
ansible.builtin.git:
accept_newhostkey: true
clone: true
force: true
recursive: false
repo: https://github.com/nvm-sh/nvm
dest: "{{ home }}/.nvm"
- name: Install node and set version
tags:
- config
become_user: "{{ username }}"
register: nodeinstall
ansible.builtin.shell: source {{ home }}/.nvm/nvm.sh && nvm install 22
changed_when: "'is already installed' not in nodeinstall.stderr"
args:
executable: /bin/bash
- name: Setup config dirctories
tags:
- config
ansible.builtin.file:
mode: "{{ item.mode }}"
path: "{{ home }}/{{ item.path }}"
owner: "{{ username }}"
state: directory
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'directory'
- name: Copy config {{ context }}
tags:
- config
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ home }}/{{ item.path }}"
mode: "{{ item.mode }}"
owner: "{{ username }}"
with_community.general.filetree:
- ../files
loop_control:
label: "{{ item.path }}"
when: item.state == 'file'