Skip to content
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

Updating-nodejs #2262

Merged
merged 9 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roles/aws/aws_ec2_autoscale_cluster/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
- aws_ec2_autoscale_cluster.deploy_cluster

- name: Create launch template.
community.aws.ec2_launch_template:
amazon.aws.ec2_launch_template:
profile: "{{ aws_ec2_autoscale_cluster.aws_profile }}"
name: "{{ aws_ec2_autoscale_cluster.name }}"
image_id: "{{ aws_ec2_autoscale_cluster.image_id if aws_ec2_autoscale_cluster.image_id is defined else aws_ec2_autoscale_cluster_image_latest.image_id }}"
Expand Down
4 changes: 2 additions & 2 deletions roles/aws/aws_ec2_autoscale_cluster/tasks/peering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
register: _aws_ec2_autoscale_cluster_peer_vpc

- name: Create local VPC peering Connection
community.aws.ec2_vpc_peer:
amazon.aws.ec2_vpc_peering:
profile: "{{ aws_ec2_autoscale_cluster.aws_profile }}"
region: "{{ aws_ec2_autoscale_cluster.region }}"
vpc_id: "{{ _aws_ec2_autoscale_cluster_vpc.vpcs[0].vpc_id }}"
Expand All @@ -27,7 +27,7 @@
register: _aws_ec2_autoscale_cluster_peer_connection

- name: Accept VPC peering request.
community.aws.ec2_vpc_peer:
amazon.aws.ec2_vpc_peering:
profile: "{{ aws_ec2_autoscale_cluster.aws_profile }}"
region: "{{ aws_ec2_autoscale_cluster.region }}"
peering_id: "{{ _aws_ec2_autoscale_cluster_peer_connection.peering_id }}"
Expand Down
3 changes: 2 additions & 1 deletion roles/debian/nodejs/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
nodejs:
# Used by apt_unattended_upgrades
apt_origin_nodejs: "origin=Node Source,codename=nodistro,label=Node Source" # nodejs repo
apt_origin_nodejs: "origin=. nodistro,codename=nodistro,label=. nodistro" # nodejs repo
apt_origin_nodejs_old: "origin=Node Source,codename=${distro_codename},label=Node Source" # nodejs repo
apt_signed_by_nodejs: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
apt_origin_yarn: "origin=yarn,codename=stable,label=yarn-stable" # yarn repo
apt_signed_by_yarn: https://dl.yarnpkg.com/debian/pubkey.gpg
Expand Down
63 changes: 53 additions & 10 deletions roles/debian/nodejs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
---
- name: Add NodeJS repository and key.
- name: Add NodeJS repository and key
ansible.builtin.include_role:
name: debian/apt_repository
vars:
apt_repository:
nodejs_old_config:
legacy_repo: "deb https://deb.nodesource.com/node_{{ nodejs.version }} {{ ansible_distribution_release }} main"
format: deb822
name: nodejs
types:
- deb
- deb-src
uris:
- "https://deb.nodesource.com/node_{{ nodejs.version }}"
suites: "{{ ansible_distribution_release }}"
components:
- main
signed_by: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
state: present
enabled: true
key_refresh_timer_OnCalendar: "Mon *-*-* 00:15:00"
nodejs_default_config:
legacy_repo: "deb https://deb.nodesource.com/node_{{ nodejs.version }} nodistro main"
format: deb822
name: nodejs
Expand All @@ -18,14 +33,33 @@
state: present
enabled: true
key_refresh_timer_OnCalendar: "Mon *-*-* 00:15:00"
apt_repository: "{{ nodejs_old_config if (nodejs.version | regex_replace('\\.x$', '') | int) < 16 else nodejs_default_config }}"

- name: Modify repository for Node.js 10.x
set_fact:
apt_repository:
types: "deb deb-src"
suites: "{{ ansible_distribution_release }}"
signed_by: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
when: nodejs.version == "10.x"
- name: Get current Nodejs version
ansible.builtin.command: node -v
register: current_nodejs_version
failed_when: false
changed_when: false

- name: Extract the major version of the current Nodejs version so we can compare & condition properly
ansible.builtin.set_fact:
current_major_version: "{{ current_nodejs_version.stdout | regex_replace('v([0-9]+).*', '\\1') }}"

- name: Remove Nodejs if it differs from current nodejs.version
ansible.builtin.apt:
name: nodejs
state: absent
when:
- nodejs.version is defined
- (nodejs.version | regex_replace('\\.x$', '')) != current_major_version

- name: Install the specified Nodejs version if nodejs.version is defined and different from current version
ansible.builtin.apt:
name: "nodejs"
state: present
when:
- nodejs.version is defined
- (nodejs.version | regex_replace('\\.x$', '')) != current_major_version

- name: Add Yarn repository and key.
ansible.builtin.include_role:
Expand Down Expand Up @@ -62,6 +96,15 @@
when:
- apt_unattended_upgrades.enable is defined
- apt_unattended_upgrades.enable
- (nodejs.version | regex_replace('\\.x$', '')) | int >= 16

- name: Add nodejs and yarn repositories to unattended-upgrades origins list.
ansible.builtin.set_fact:
_apt_unattended_upgrades_default_origins: "{{ _apt_unattended_upgrades_default_origins + [nodejs.apt_origin_nodejs_old, nodejs.apt_origin_yarn] }}"
when:
- apt_unattended_upgrades.enable is defined
- apt_unattended_upgrades.enable
- (nodejs.version | regex_replace('\\.x$', '')) | int < 16

- name: Install the unattended-upgrades config.
ansible.builtin.include_role:
Expand Down
Loading