ilia c5ae3af9ac Add tasks to manage repository files and ensure directory permissions
- Clean up duplicate Brave repository files in applications role.
- Ensure Ansible remote_tmp directory exists with correct permissions in base role.
- Remove existing NodeSource repository files and create keyrings directory in development role.

These changes improve package management and maintain a clean repository setup across roles.
2025-09-09 22:46:31 -04:00

71 lines
2.0 KiB
YAML

---
- name: Install basic development packages
ansible.builtin.apt:
name:
# Development tools
- git
# Build tools
- build-essential
- python3
- python3-pip
state: present
become: true
- name: Check if NodeSource Node.js is installed
ansible.builtin.command: node --version
register: node_version_check
failed_when: false
changed_when: false
- name: Remove existing NodeSource repository files
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /etc/apt/sources.list.d/nodesource.list
- /etc/apt/sources.list.d/nodesource.list.save
become: true
failed_when: false
when: node_version_check.rc != 0 or not node_version_check.stdout.startswith('v2')
- name: Create keyrings directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
become: true
when: node_version_check.rc != 0 or not node_version_check.stdout.startswith('v2')
- name: Add NodeSource GPG key
ansible.builtin.get_url:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
dest: /etc/apt/keyrings/nodesource.asc
mode: '0644'
force: true
become: true
when: node_version_check.rc != 0 or not node_version_check.stdout.startswith('v2')
- name: Add NodeSource repository
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_22.x nodistro main"
state: present
update_cache: false
become: true
when: node_version_check.rc != 0 or not node_version_check.stdout.startswith('v2')
- name: Install Node.js 22 from NodeSource
ansible.builtin.apt:
name: nodejs
state: present
become: true
when: node_version_check.rc != 0 or not node_version_check.stdout.startswith('v2')
- name: Verify Node.js installation
ansible.builtin.command: node --version
register: final_node_version
changed_when: false
- name: Display Node.js version
ansible.builtin.debug:
msg: "Node.js version installed: {{ final_node_version.stdout }}"