From 038cb6ccb0fef28d189eca5b027ce212f56479de Mon Sep 17 00:00:00 2001 From: Voursstrreds Date: Tue, 31 Oct 2023 23:37:32 +0300 Subject: [PATCH 1/3] Redefine roles, rewrite readme --- roles/colcon_build/README.md | 12 ++++++++---- roles/colcon_build/templates/colcon_build.sh.j2 | 2 +- roles/repositories/README.md | 17 +++++++---------- roles/repositories/defaults/main.yml | 3 --- roles/repositories/tasks/from_file.yml | 2 +- roles/repositories/tasks/from_variable.yml | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/roles/colcon_build/README.md b/roles/colcon_build/README.md index 4d8e21e..8af8565 100644 --- a/roles/colcon_build/README.md +++ b/roles/colcon_build/README.md @@ -1,7 +1,7 @@ -REPOSITORIES +COLCON BUILD ========= -Reads repos file contents similar to existing VCS tool, downloads the repositories in indicated repos file. Downloads repositories from dictionary lists. +Runs the `colcon build` command. ![Ansible Lint](https://github.com/bounverif/ansible-collection-ros/actions/workflows/ansible-lint.yml/badge.svg) @@ -27,6 +27,7 @@ Two global variables must be defined to use this role. Definitions and required | colcon_build_continue_on_error | no| `false` | `bool value` | Continue execution even if an error occurs. For details see Colcon documentation. | | colcon_build_use_cmake_args | no | `true` | `bool value` | Indicates whether user cmake args flag or not. | | colcon_build_cmake_args | no | `"-DCMAKE_BUILD_TYPE=Release"`| `directory path` | CMake arguments that will be called while CMake running. | +| colcon_build_packages_up_to | no | `no default` | `list of package names (string)` | Packages are installed up to given package name. For more details see Colcon documentation. | Dependencies @@ -41,17 +42,20 @@ An example playbook is provided below: ``` --- -- name: Colcon Build Role - File Read +- name: Colcon Build Role hosts: localhost connection: local vars: - repos_directory: "/tmp/ros/workspace/" + ros_workspace: "/tmp/workspace/" colcon_build_build_base_dir: "/tmp/workspace/build" colcon_build_install_base_dir: "/tmp/workspace/install" colcon_build_symlink_install: true colcon_build_use_cmake_args: true colcon_build_cmake_args: "-DCMAKE_BUILD_TYPE=Release" + colcon_build_packages_up_to: + - package1 + - package2 roles: - role: bounverif.ros.colcon_build diff --git a/roles/colcon_build/templates/colcon_build.sh.j2 b/roles/colcon_build/templates/colcon_build.sh.j2 index f3b9a4a..a6db3e7 100644 --- a/roles/colcon_build/templates/colcon_build.sh.j2 +++ b/roles/colcon_build/templates/colcon_build.sh.j2 @@ -6,4 +6,4 @@ colcon build {% if colcon_build_test_result_base %}--test-result-base {{ colcon_build_test_result_base_dir }}{% endif %} {% if colcon_build_continue_on_error %}--continue-on-error{% endif %} {% if colcon_build_use_cmake_args %}--cmake-args {{ colcon_build_cmake_args }}{% endif %} - {% if colcon_build_packages_up_to %}--packages-up-to {% for __dependency in colcon_build_packages_up_to %} {{ __dependency }} {% endfor %}{% endif %} + {% if colcon_build_packages_up_to is defined %}--packages-up-to {% for __dependency in colcon_build_packages_up_to %} {{ __dependency }} {% endfor %}{% endif %} diff --git a/roles/repositories/README.md b/roles/repositories/README.md index 08cb379..5992f7b 100644 --- a/roles/repositories/README.md +++ b/roles/repositories/README.md @@ -8,14 +8,12 @@ Reads repos file contents similar to existing VCS tool, downloads the repositori Requirements ------------ -A valid path to a directory in which includes files written in `repos` format, or a valid list constructed by dictionaries which have `ansible.builtin.git` module's parameters. +A valid path to a directory in which includes files written in `repos` format no matter what is the file name, or a valid list constructed by dictionaries which have `ansible.builtin.git` module's parameters. -For file reading define `repositories_source_dir` which is a string of a relative or absolute directory path, that directory can also be defined by defining `ROS_WORKSPACE` environment variable. Define `repositories_files` that is a list of strings constructed by file names. Do not define any `repositories` named list or variable. Define `repositories_download_dir` as a directory, if the repository is not defined a specific `dest` value, then the files will be downloaded onto `repositories_download_dir`. +For file reading define `repositories_files` which is a string of a relative or absolute directory path. Define `repositories_files` that is a list of strings constructed by only file names. The repository will read `/files/` directory in the collection. Do not define any `repositories` named list or variable. Until then, it will work same as the VCS tool. Also define `collection_name` as the real collection name. For variable reading define a `repositories` list variable which consists of dictionaries that have parameters of `ansible.builtin.git` module. Do not define the variable `repositories_files`. -Additionally, for all cases, do not define a variable named `repositories_file_path_list`, this is a meta-variable reserved for calculations. - Role Variables -------------- @@ -23,10 +21,10 @@ These variables must be defined according to the usage to use this role. Definit | Variable | Required | Default | Choices | Comments | |-------------------------|----------|--------------|---------------------------|------------------------------------------| -| repositories_source_dir | yes | `no default` | `directory path` | A directory name. Required when read_repositories_from_file is set `true`. | -| repositories_download_dir | yes | `no default` | `directory path` | Indicates a prefix path where to download repositories, which will be joined with the path on `key` value on repos file. Used when `dest` parameter on git parameter is not set. | +| ros_source_dir | yes | `no default` | `directory path` | A directory name. Required when read_repositories_from_file is set `true`. | | repositories | yes | `no default` | `list of dictionaries` | List of dictionaries with fields named as git builtin. Do not define if `repositories_files` set. | | repositories_files | yes | `no default` | `list of file names` | Names of files will be read. If defined, then the role will read files instead of `repositories` list.| +| collection_name | yes | `no default` | `name of collection` | Name of your own collection. | Dependencies @@ -45,8 +43,7 @@ An example playbook using file read feature, runs this role on localhost. For th hosts: localhost connection: local vars: - repositories_source_dir: "/tmp/ros/examples/sample_repos_file/" - repositories_download_dir: "/tmp/ros/src" + ros_source_dir: "/tmp/ros/examples/sample_repos_file/" repositories_files: - file1.repos - file2.yaml @@ -61,8 +58,8 @@ An example playbook using file read feature, runs this role on localhost. For th connection: local vars: repositories: - - { url: https://github.com/some/git/repository1.git, dest: "/to/some/download/path/", version: main } - - { url: https://github.com/some/git/repository2.git, dest: "/to/some/download/path/", version: main } + - { url: https://github.com/some/git/repository1.git, dest: "to/some/download/path/", version: main } + - { url: https://github.com/some/git/repository2.git, dest: "to/some/download/path/", version: main } roles: - role: bounverif.ros.repositories ``` diff --git a/roles/repositories/defaults/main.yml b/roles/repositories/defaults/main.yml index bb72659..3c3a96b 100644 --- a/roles/repositories/defaults/main.yml +++ b/roles/repositories/defaults/main.yml @@ -1,4 +1 @@ -repositories_source_dir: "{{ lookup('ansible.builtin.env', 'ROS_WORKSPACE', default='') }}" -repositories_download_dir: "{{ ros_source_dir }}" repositories: {} -repositories_file_path_list: [] diff --git a/roles/repositories/tasks/from_file.yml b/roles/repositories/tasks/from_file.yml index 436a8f1..1b82fee 100644 --- a/roles/repositories/tasks/from_file.yml +++ b/roles/repositories/tasks/from_file.yml @@ -1,6 +1,6 @@ - name: Load Repos Files ansible.builtin.include_vars: - file: "{{ item }}" + file: "../../../{{ collection_name }}/files/{{ item }}" hash_behaviour: "merge" name: repositories loop: "{{ repositories_files }}" diff --git a/roles/repositories/tasks/from_variable.yml b/roles/repositories/tasks/from_variable.yml index ea5decd..0273a2a 100644 --- a/roles/repositories/tasks/from_variable.yml +++ b/roles/repositories/tasks/from_variable.yml @@ -1,7 +1,7 @@ - name: Clone Repositories ansible.builtin.git: repo: "{{ item.url }}" - dest: "{{ item.dest }}" + dest: "{{ ([ros_source_dir, item.dest] | path_join) }}" version: "{{ item.version | default(omit) }}" depth: "{{ item.depth | default(omit) }}" single_branch: "{{ item.single_branch | default(omit) }}" From cbb25d42d672b578aa0435a4752153ea5433257f Mon Sep 17 00:00:00 2001 From: Voursstrreds Date: Wed, 1 Nov 2023 21:56:34 +0300 Subject: [PATCH 2/3] Change path join --- roles/repositories/tasks/from_file.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/repositories/tasks/from_file.yml b/roles/repositories/tasks/from_file.yml index 1b82fee..e4621ed 100644 --- a/roles/repositories/tasks/from_file.yml +++ b/roles/repositories/tasks/from_file.yml @@ -1,6 +1,6 @@ - name: Load Repos Files ansible.builtin.include_vars: - file: "../../../{{ collection_name }}/files/{{ item }}" + file: "{{ ([ '..', '..', '..', collection_name, files, item ] | path_join ) }}" hash_behaviour: "merge" name: repositories loop: "{{ repositories_files }}" From b8dbb3e1b189b11aaf0f60586d285d0597b66c5e Mon Sep 17 00:00:00 2001 From: Voursstrreds Date: Wed, 1 Nov 2023 23:47:59 +0300 Subject: [PATCH 3/3] ss --- roles/ros2_install/defaults/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/ros2_install/defaults/main.yml b/roles/ros2_install/defaults/main.yml index c716c3d..105a4dc 100644 --- a/roles/ros2_install/defaults/main.yml +++ b/roles/ros2_install/defaults/main.yml @@ -1,2 +1,3 @@ ros2_install_packages: - ros-{{ ros_distro }}-ros-base + - ros-dev-tools