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

feat: escape install task if the specific package is held #4584

Closed
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: 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 @@

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.

Check warning on line 7 in ansible/roles/ros2/README.md

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (warining)

<!-- 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: Check if ros-{{ rosdistro }}-{{ ros2_installation_type }} is held

Check failure on line 37 in ansible/roles/ros2/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / pre-commit-ansible

fqcn[action-core]

Use FQCN for builtin module actions (command).

Check failure on line 37 in ansible/roles/ros2/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / pre-commit-ansible

name[template]

Jinja templates should only be at the end of 'name'
command: apt-mark showhold

Check warning on line 38 in ansible/roles/ros2/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (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

Check failure on line 52 in ansible/roles/ros2/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / pre-commit-ansible

literal-compare

Don't compare to literal True/False.

Check failure on line 52 in ansible/roles/ros2/tasks/main.yaml

View workflow job for this annotation

GitHub Actions / pre-commit-ansible

no-handler

Tasks that run when changed should likely be handlers.
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:
Expand Down
Loading