From f3b45d97439667e6fc9dfc4008cedc772b125d2c Mon Sep 17 00:00:00 2001 From: Naophis Date: Tue, 2 Apr 2024 16:46:35 +0900 Subject: [PATCH 1/5] feat: escape install task if the specific package is held Signed-off-by: Naophis --- ansible/roles/ros2/README.md | 2 ++ ansible/roles/ros2/tasks/main.yaml | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/ansible/roles/ros2/README.md b/ansible/roles/ros2/README.md index 54fb39e0a94..56c624b9148 100644 --- a/ansible/roles/ros2/README.md +++ b/ansible/roles/ros2/README.md @@ -4,6 +4,8 @@ This role installs [ROS 2](http://www.ros2.org/) following [this page](https://d Additional steps may be needed depending on the `rosdistro` you choose. +To prevent the update of the ROS 2 packages, if ros-`distro`-desktop is held, the installation process for the packages will be skipped and output warining. + ```bash diff --git a/ansible/roles/ros2/tasks/main.yaml b/ansible/roles/ros2/tasks/main.yaml index ab77bb632c1..bf0fa6b3d25 100644 --- a/ansible/roles/ros2/tasks/main.yaml +++ b/ansible/roles/ros2/tasks/main.yaml @@ -34,12 +34,25 @@ state: present update_cache: true +- name: Check if ros-{{ rosdistro }}-{{ ros2_installation_type }} is held + command: apt-mark showhold + register: held_ros_packages + changed_when: false + - name: Install ros-{{ rosdistro + '-' + ros2_installation_type }} become: true ansible.builtin.apt: name: ros-{{ rosdistro }}-{{ ros2_installation_type }} state: latest update_cache: true + when: "'ros-' + rosdistro + '-' + ros2_installation_type not in held_ros_packages.stdout" + register: install_result + failed_when: false + +- name: Display warning if ROS 2 package is held + ansible.builtin.debug: + msg: ROS package 'ros-{{ rosdistro + '-' + ros2_installation_type }}' is apt-mark hold. Skipping installation. + when: install_result.changed == false - name: Add PATH to .bashrc ansible.builtin.lineinfile: From 6adefc191eabf1f03150eb707341cdc7670fb65d Mon Sep 17 00:00:00 2001 From: Naophis Date: Tue, 2 Apr 2024 17:07:19 +0900 Subject: [PATCH 2/5] feat: use FQCN Signed-off-by: Naophis --- ansible/roles/ros2/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/ros2/tasks/main.yaml b/ansible/roles/ros2/tasks/main.yaml index bf0fa6b3d25..192d649fef0 100644 --- a/ansible/roles/ros2/tasks/main.yaml +++ b/ansible/roles/ros2/tasks/main.yaml @@ -35,7 +35,7 @@ update_cache: true - name: Check if ros-{{ rosdistro }}-{{ ros2_installation_type }} is held - command: apt-mark showhold + ansible.builtin.command: apt-mark showhold register: held_ros_packages changed_when: false From 4484d62320c8cd7c6c0c7a765fb985aa6e341b21 Mon Sep 17 00:00:00 2001 From: Naophis Date: Tue, 2 Apr 2024 17:17:35 +0900 Subject: [PATCH 3/5] feat: Jinja templates should only be at the end of 'name' Signed-off-by: Naophis --- ansible/roles/ros2/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/ros2/tasks/main.yaml b/ansible/roles/ros2/tasks/main.yaml index 192d649fef0..50100e40adb 100644 --- a/ansible/roles/ros2/tasks/main.yaml +++ b/ansible/roles/ros2/tasks/main.yaml @@ -34,7 +34,7 @@ state: present update_cache: true -- name: Check if ros-{{ rosdistro }}-{{ ros2_installation_type }} is held +- name: Hold check of ros-{{ rosdistro + '-' + ros2_installation_type }} ansible.builtin.command: apt-mark showhold register: held_ros_packages changed_when: false From 9b6b6cc197304635cc787fe1546a71ab14f1177c Mon Sep 17 00:00:00 2001 From: Naophis Date: Tue, 2 Apr 2024 17:28:32 +0900 Subject: [PATCH 4/5] fix: change literal Signed-off-by: Naophis --- ansible/roles/ros2/tasks/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/ros2/tasks/main.yaml b/ansible/roles/ros2/tasks/main.yaml index 50100e40adb..9ad8bb165f9 100644 --- a/ansible/roles/ros2/tasks/main.yaml +++ b/ansible/roles/ros2/tasks/main.yaml @@ -52,7 +52,7 @@ - name: Display warning if ROS 2 package is held ansible.builtin.debug: msg: ROS package 'ros-{{ rosdistro + '-' + ros2_installation_type }}' is apt-mark hold. Skipping installation. - when: install_result.changed == false + when: not install_result.changed - name: Add PATH to .bashrc ansible.builtin.lineinfile: From f9207d58103093c8a48231ee330f328cbb8f34e8 Mon Sep 17 00:00:00 2001 From: Naophis Date: Tue, 2 Apr 2024 17:37:28 +0900 Subject: [PATCH 5/5] doc: fix typo Signed-off-by: Naophis --- ansible/roles/ros2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/ros2/README.md b/ansible/roles/ros2/README.md index 56c624b9148..07fab9500b8 100644 --- a/ansible/roles/ros2/README.md +++ b/ansible/roles/ros2/README.md @@ -4,7 +4,7 @@ This role installs [ROS 2](http://www.ros2.org/) following [this page](https://d Additional steps may be needed depending on the `rosdistro` you choose. -To prevent the update of the ROS 2 packages, if ros-`distro`-desktop is held, the installation process for the packages will be skipped and output warining. +To prevent the update of the ROS 2 packages, if ros-`distro`-desktop is held, the installation process for the packages will be skipped and output warning.