diff --git a/roles/aws/aws_ec2_autoscale_cluster/tasks/main.yml b/roles/aws/aws_ec2_autoscale_cluster/tasks/main.yml index fdc8384c6..5d91d19c8 100644 --- a/roles/aws/aws_ec2_autoscale_cluster/tasks/main.yml +++ b/roles/aws/aws_ec2_autoscale_cluster/tasks/main.yml @@ -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 }}" diff --git a/roles/aws/aws_ec2_autoscale_cluster/tasks/peering.yml b/roles/aws/aws_ec2_autoscale_cluster/tasks/peering.yml index e1baa76e5..58d3f4b12 100644 --- a/roles/aws/aws_ec2_autoscale_cluster/tasks/peering.yml +++ b/roles/aws/aws_ec2_autoscale_cluster/tasks/peering.yml @@ -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 }}" @@ -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 }}" diff --git a/roles/debian/nodejs/defaults/main.yml b/roles/debian/nodejs/defaults/main.yml index 0ae6c011c..a5abfea38 100644 --- a/roles/debian/nodejs/defaults/main.yml +++ b/roles/debian/nodejs/defaults/main.yml @@ -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 diff --git a/roles/debian/nodejs/tasks/main.yml b/roles/debian/nodejs/tasks/main.yml index 0806e47f5..185bcb6e3 100644 --- a/roles/debian/nodejs/tasks/main.yml +++ b/roles/debian/nodejs/tasks/main.yml @@ -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 @@ -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: @@ -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: