From d3128dab9528c44c58b7e1bff2eb834578b3cb70 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 13 Sep 2017 14:56:21 -0600 Subject: [PATCH] Fix linting issues found via project-config There are no playbooks that use the roles in this repo in a way that would lint them, however running linters in project-config found numerous issues in these roles. Correct the roles. Change-Id: I017532c8aed8fd90474052423c7ba2510cf84631 Signed-off-by: Jesse Keating --- roles/configure-mirrors/handlers/main.yaml | 5 +- roles/emit-job-header/tasks/main.yaml | 3 +- .../tasks/main.yaml | 68 +++++++++++-------- roles/upload-logs/tasks/main.yaml | 3 +- 4 files changed, 46 insertions(+), 33 deletions(-) diff --git a/roles/configure-mirrors/handlers/main.yaml b/roles/configure-mirrors/handlers/main.yaml index 0b1352ac3..ab031fcf7 100644 --- a/roles/configure-mirrors/handlers/main.yaml +++ b/roles/configure-mirrors/handlers/main.yaml @@ -3,6 +3,9 @@ - name: Update apt cache become: yes command: apt-get update + # skip linting for above comment + tags: + - skip_ansible_lint - name: Update dnf cache become: yes @@ -23,4 +26,4 @@ command: "{{ item }}" with_items: - zypper clean - - zypper refresh \ No newline at end of file + - zypper refresh diff --git a/roles/emit-job-header/tasks/main.yaml b/roles/emit-job-header/tasks/main.yaml index 93e962887..2bb7ec249 100644 --- a/roles/emit-job-header/tasks/main.yaml +++ b/roles/emit-job-header/tasks/main.yaml @@ -1,4 +1,5 @@ -- include_role: +- name: include the log path role + include_role: name: set-zuul-log-path-fact - debug: diff --git a/roles/mirror-workspace-git-repos/tasks/main.yaml b/roles/mirror-workspace-git-repos/tasks/main.yaml index 986b7b4a5..b656049d1 100644 --- a/roles/mirror-workspace-git-repos/tasks/main.yaml +++ b/roles/mirror-workspace-git-repos/tasks/main.yaml @@ -1,35 +1,43 @@ - name: Allow pushing to non-bare repo - command: "git config --local receive.denyCurrentBranch ignore" - args: - chdir: "{{ ansible_user_dir }}/{{ item.src_dir}}" + git_config: + scope: local + name: receive.denyCurrentBranch + value: ignore + repo: "{{ ansible_user_dir }}/{{ item.src_dir}}" with_items: "{{ zuul.projects }}" -- name: Synchronize src repos to workspace directory - command: "git push --mirror git+ssh://{{ ansible_user }}@{{ ansible_host }}/{{ ansible_user_dir }}/{{ item.src_dir}}" - args: - chdir: "{{ zuul.executor.work_root }}/{{ item.src_dir }}" - with_items: "{{ zuul.projects }}" - delegate_to: localhost +- block: + # Do not lint these tasks, gets confused by git actions that cannot be done + # by git modules + tags: + - skip_ansible_lint -- name: Determine local HEAD - shell: "git status |head -1 |awk '{ print $NF }'" - args: - chdir: "{{ zuul.executor.work_root }}/{{ item.src_dir }}" - with_items: "{{ zuul.projects }}" - delegate_to: localhost - register: statuses + - name: Synchronize src repos to workspace directory + command: "git push --mirror git+ssh://{{ ansible_user }}@{{ ansible_host }}/{{ ansible_user_dir }}/{{ item.src_dir}}" + args: + chdir: "{{ zuul.executor.work_root }}/{{ item.src_dir }}" + with_items: "{{ zuul.projects }}" + delegate_to: localhost -# Do this as a multi-line shell so that we can do the loop once -- name: Update remote repository state correctly - shell: | - # Reset is needed because we pushed to a non-bare repo - git reset --hard - # Undo the config setting we did above - git config --local --unset receive.denyCurrentBranch - # checkout the branch matching the branch set up by the executor - git checkout {{ item.1.stdout }} - args: - chdir: "{{ ansible_user_dir }}/{{ item.0.src_dir }}" - with_together: - - "{{ zuul.projects }}" - - "{{ statuses.results }}" + - name: Determine local HEAD + shell: "git status |head -1 |awk '{ print $NF }'" + args: + chdir: "{{ zuul.executor.work_root }}/{{ item.src_dir }}" + with_items: "{{ zuul.projects }}" + delegate_to: localhost + register: statuses + + # Do this as a multi-line shell so that we can do the loop once + - name: Update remote repository state correctly + shell: | + # Reset is needed because we pushed to a non-bare repo + git reset --hard + # Undo the config setting we did above + git config --local --unset receive.denyCurrentBranch + # checkout the branch matching the branch set up by the executor + git checkout {{ item.1.stdout }} + args: + chdir: "{{ ansible_user_dir }}/{{ item.0.src_dir }}" + with_together: + - "{{ zuul.projects }}" + - "{{ statuses.results }}" diff --git a/roles/upload-logs/tasks/main.yaml b/roles/upload-logs/tasks/main.yaml index 36e986d79..b0f7a624f 100644 --- a/roles/upload-logs/tasks/main.yaml +++ b/roles/upload-logs/tasks/main.yaml @@ -1,4 +1,5 @@ -- include_role: +- name: include the log path role + include_role: name: set-zuul-log-path-fact - name: Create log directories