Adrià Vilanova MartÃnez | 8fe5213 | 2024-09-29 12:43:09 +0200 | [diff] [blame] | 1 | - name: Update apt cache |
| 2 | apt: |
| 3 | update_cache: yes |
| 4 | become: yes |
| 5 | |
| 6 | - name: Install prereqs |
| 7 | package: |
| 8 | name: apt-transport-https |
| 9 | state: present |
| 10 | become: yes |
| 11 | |
| 12 | - name: Pin nodejs installs to nodesource |
| 13 | copy: |
| 14 | src: 00-nodesource.pref |
| 15 | dest: /etc/apt/preferences.d/00-nodesource.pref |
| 16 | mode: 0644 |
| 17 | become: yes |
| 18 | |
| 19 | - name: Add all repositories |
| 20 | include_role: |
| 21 | name: ensure-package-repositories |
| 22 | vars: |
| 23 | repositories_keys: |
| 24 | - url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key |
| 25 | repositories_list: |
| 26 | - repo: deb-src https://deb.nodesource.com/node_{{ node_version }}.x {{ ansible_distribution_release }} main |
| 27 | - repo: deb https://deb.nodesource.com/node_{{ node_version }}.x {{ ansible_distribution_release }} main |
| 28 | when: node_version | int < 16 |
| 29 | |
| 30 | - name: Add all repositories |
| 31 | include_role: |
| 32 | name: ensure-package-repositories |
| 33 | vars: |
| 34 | repositories_keys: |
| 35 | - url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key |
| 36 | repositories_list: |
| 37 | - repo: deb https://deb.nodesource.com/node_{{ node_version }}.x nodistro main |
| 38 | when: node_version | int >= 16 |
| 39 | |
| 40 | # Use template so that we can easily update this in the future to be able to |
| 41 | # use a mirror location. |
| 42 | - name: Pin NodeJS to nodesource apt repository |
| 43 | become: yes |
| 44 | template: |
| 45 | dest: /etc/apt/preferences.d/nodejs.pref |
| 46 | group: root |
| 47 | mode: 0644 |
| 48 | owner: root |
| 49 | src: nodejs.pref.j2 |
| 50 | |
| 51 | - name: Install NodeJS from nodesource |
| 52 | package: |
| 53 | name: nodejs |
| 54 | state: latest |
| 55 | become: yes |
| 56 | tags: |
| 57 | # Ignore ANSIBLE0010: We really want latest version |
| 58 | - skip_ansible_lint |
| 59 | |
| 60 | - name: Output node version |
| 61 | command: node --version |
| 62 | |
| 63 | - name: Output npm version |
| 64 | command: npm --version |