Skip to content

Commit

Permalink
feat: escape install task if the specific package is held (autowarefo…
Browse files Browse the repository at this point in the history
…undation#4585)

* feat: escape install task if the specific package is held

Signed-off-by: Naophis <[email protected]>

* feat: use FQCN

Signed-off-by: Naophis <[email protected]>

* feat:  Jinja templates should only be at the end of 'name'

Signed-off-by: Naophis <[email protected]>

* fix: change literal

Signed-off-by: Naophis <[email protected]>

* doc: fix typo

Signed-off-by: Naophis <[email protected]>

---------

Signed-off-by: Naophis <[email protected]>
  • Loading branch information
Naophis authored Apr 5, 2024
1 parent 918a067 commit fb51159
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ansible/roles/ros2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 warning.

<!-- TODO: Add these steps to the role if Humble requires. -->

```bash
Expand Down
13 changes: 13 additions & 0 deletions ansible/roles/ros2/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,25 @@
state: present
update_cache: true

- name: Hold check of ros-{{ rosdistro + '-' + ros2_installation_type }}
ansible.builtin.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: not install_result.changed

- name: Add PATH to .bashrc
ansible.builtin.lineinfile:
Expand Down

0 comments on commit fb51159

Please sign in to comment.