From 55d58c389c065df3d33acf82f7379a6022ab0741 Mon Sep 17 00:00:00 2001 From: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> Date: Mon, 21 Feb 2022 18:11:14 +0900 Subject: [PATCH] fix(ansible/docker): replace `lineinfile` with `copy` not to write duplicated entries (#66) * fix(setup): remove apt ansible before installing by pip Signed-off-by: Kenji Miyake * refactor: change task order Signed-off-by: Kenji Miyake * fix(ansible/docker): replace `lineinfile` with `copy` not to write duplicated entries Signed-off-by: Kenji Miyake * chore: remove paths condition to make it required for PRs Signed-off-by: Kenji Miyake --- .github/workflows/vcs-import.yaml | 2 -- ansible/roles/docker/tasks/main.yaml | 17 +++++++---------- setup-dev-env.sh | 1 + 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/vcs-import.yaml b/.github/workflows/vcs-import.yaml index c37a4c19204..a657f6e5afe 100644 --- a/.github/workflows/vcs-import.yaml +++ b/.github/workflows/vcs-import.yaml @@ -2,8 +2,6 @@ name: vcs-import on: pull_request: - paths: - - autoware.repos workflow_dispatch: jobs: diff --git a/ansible/roles/docker/tasks/main.yaml b/ansible/roles/docker/tasks/main.yaml index f08e181d85b..db057b35289 100644 --- a/ansible/roles/docker/tasks/main.yaml +++ b/ansible/roles/docker/tasks/main.yaml @@ -70,16 +70,16 @@ groups: docker append: true -- name: Save result of '. /etc/os-release;echo $ID$VERSION_ID' - ansible.builtin.shell: . /etc/os-release;echo $ID$VERSION_ID - register: distribution - changed_when: false - - name: Authorize NVIDIA Docker GPG key become: true ansible.builtin.apt_key: url: https://nvidia.github.io/nvidia-docker/gpgkey +- name: Save result of '. /etc/os-release;echo $ID$VERSION_ID' + ansible.builtin.shell: . /etc/os-release;echo $ID$VERSION_ID + register: distribution + changed_when: false + - name: Save result of 'curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list' ansible.builtin.uri: url: https://nvidia.github.io/nvidia-docker/{{ distribution.stdout }}/nvidia-docker.list @@ -89,13 +89,10 @@ # curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list - name: Add NVIDIA Docker apt repository to source list become: true - ansible.builtin.lineinfile: + ansible.builtin.copy: dest: /etc/apt/sources.list.d/nvidia-docker.list - line: "{{ item }}" - state: present - create: true + content: "{{ nvidia_docker_list.content }}" mode: 0644 - with_items: "{{ nvidia_docker_list.content }}" - name: Install NVIDIA Container Toolkit become: true diff --git a/setup-dev-env.sh b/setup-dev-env.sh index 0dffbf2b05a..fa18b82edef 100755 --- a/setup-dev-env.sh +++ b/setup-dev-env.sh @@ -85,6 +85,7 @@ fi # Install ansible ansible_version=$(pip3 list | grep -oP "^ansible\s+\K([0-9]+)" || true) if [ "$ansible_version" != "5" ]; then + sudo apt-get -y purge ansible sudo pip3 install -U "ansible==5.*" fi