From 89039cdbb4223383eebf5467f7f22c0138c68ed1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 12 2020 10:59:09 +0000 Subject: [PATCH 1/8] Add basic zuul configuration to run ansible-review Signed-off-by: Pierre-Yves Chibon Signed-off-by: Nils Philippsen --- diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..f735ec8 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,8 @@ +- job: + name: ansible-review + run: ci/ansible-review.yaml + +- project: + check: + jobs: + - ansible-review diff --git a/ci/ansible-review.yaml b/ci/ansible-review.yaml new file mode 100644 index 0000000..8191d04 --- /dev/null +++ b/ci/ansible-review.yaml @@ -0,0 +1,16 @@ +- hosts: all + tasks: + - name: Install ansible-review + package: + name: python3-ansible-review + state: latest + + - name: Run ansible-review on the playbooks + shell: find playbooks -name "*.yml" -o -name "*.yaml" | xargs ansible-review + args: + chdir: '{{ zuul.project.src_dir }}' + + - name: Run ansible-review on the roles + shell: find roles -name "*.yml" -o -name "*.yaml" | xargs ansible-review + args: + chdir: '{{ zuul.project.src_dir }}' From 3c1def3b9ba0d26ff47974d2cc0e14a6a8fa125a Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: May 12 2020 10:59:09 +0000 Subject: [PATCH 2/8] Zuul: Rename job and split out shared actions This is in preparation to have a job only running `ansible-review` on the diff of a pull request. Signed-off-by: Nils Philippsen --- diff --git a/.zuul.yaml b/.zuul.yaml index f735ec8..651518d 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,8 +1,13 @@ - job: - name: ansible-review - run: ci/ansible-review.yaml + name: ansible-review-base + pre-run: ci/ansible-review-base.yaml + +- job: + name: ansible-review-everything + parent: ansible-review-base + run: ci/ansible-review-everything.yaml - project: check: jobs: - - ansible-review + - ansible-review-everything diff --git a/ci/ansible-review-base.yaml b/ci/ansible-review-base.yaml new file mode 100644 index 0000000..87d96b9 --- /dev/null +++ b/ci/ansible-review-base.yaml @@ -0,0 +1,6 @@ +- hosts: all + tasks: + - name: Install ansible-review + package: + name: python3-ansible-review + state: latest diff --git a/ci/ansible-review-everything.yaml b/ci/ansible-review-everything.yaml new file mode 100644 index 0000000..a0d60bb --- /dev/null +++ b/ci/ansible-review-everything.yaml @@ -0,0 +1,11 @@ +- hosts: all + tasks: + - name: Run ansible-review on the playbooks + shell: find playbooks -name "*.yml" -o -name "*.yaml" | xargs ansible-review + args: + chdir: '{{ zuul.project.src_dir }}' + + - name: Run ansible-review on the roles + shell: find roles -name "*.yml" -o -name "*.yaml" | xargs ansible-review + args: + chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review.yaml b/ci/ansible-review.yaml deleted file mode 100644 index 8191d04..0000000 --- a/ci/ansible-review.yaml +++ /dev/null @@ -1,16 +0,0 @@ -- hosts: all - tasks: - - name: Install ansible-review - package: - name: python3-ansible-review - state: latest - - - name: Run ansible-review on the playbooks - shell: find playbooks -name "*.yml" -o -name "*.yaml" | xargs ansible-review - args: - chdir: '{{ zuul.project.src_dir }}' - - - name: Run ansible-review on the roles - shell: find roles -name "*.yml" -o -name "*.yaml" | xargs ansible-review - args: - chdir: '{{ zuul.project.src_dir }}' From fc33575da436a336d071603098ffad389fa6b840 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: May 12 2020 10:59:09 +0000 Subject: [PATCH 3/8] Zuul: Run ansible-review on changes in PRs Signed-off-by: Nils Philippsen --- diff --git a/.zuul.yaml b/.zuul.yaml index 651518d..45126d7 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -7,7 +7,12 @@ parent: ansible-review-base run: ci/ansible-review-everything.yaml +- job: + name: ansible-review-diff + parent: ansible-review-base + run: ci/ansible-review-diff.yaml + - project: check: jobs: - - ansible-review-everything + - ansible-review-diff diff --git a/ci/ansible-review-diff.yaml b/ci/ansible-review-diff.yaml new file mode 100644 index 0000000..9e54f69 --- /dev/null +++ b/ci/ansible-review-diff.yaml @@ -0,0 +1,6 @@ +- hosts: all + tasks: + - name: Run ansible-review on the changes in the PR + shell: git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} | ansible-review + args: + chdir: '{{ zuul.project.src_dir }}' From 9e25039df18f0558132e3285807778ed8963970e Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: May 12 2020 10:59:09 +0000 Subject: [PATCH 4/8] Zuul: Filter initial warnings of ansible-review When invoking ansible-review without a configuration file, it outputs warnings on stderr. The wrapper script filters these out (we have enough warnings as it is). Signed-off-by: Nils Philippsen --- diff --git a/ci/ansible-review-base.yaml b/ci/ansible-review-base.yaml index 87d96b9..eddbd2d 100644 --- a/ci/ansible-review-base.yaml +++ b/ci/ansible-review-base.yaml @@ -4,3 +4,11 @@ package: name: python3-ansible-review state: latest + + - name: Install invocation script + copy: + src: ansible-review-filtered.sh + dest: /usr/local/bin/ansible-review-filtered.sh + owner: root + group: root + mode: '0755' diff --git a/ci/ansible-review-diff.yaml b/ci/ansible-review-diff.yaml index 9e54f69..a56d8e4 100644 --- a/ci/ansible-review-diff.yaml +++ b/ci/ansible-review-diff.yaml @@ -1,6 +1,8 @@ - hosts: all tasks: - name: Run ansible-review on the changes in the PR - shell: git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} | ansible-review + shell: > + git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} + | ansible-review-filtered.sh args: chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review-everything.yaml b/ci/ansible-review-everything.yaml index a0d60bb..8ba40d7 100644 --- a/ci/ansible-review-everything.yaml +++ b/ci/ansible-review-everything.yaml @@ -1,11 +1,11 @@ - hosts: all tasks: - name: Run ansible-review on the playbooks - shell: find playbooks -name "*.yml" -o -name "*.yaml" | xargs ansible-review + shell: find playbooks -name "*.yml" -o -name "*.yaml" | xargs ansible-review-filtered.sh args: chdir: '{{ zuul.project.src_dir }}' - name: Run ansible-review on the roles - shell: find roles -name "*.yml" -o -name "*.yaml" | xargs ansible-review + shell: find roles -name "*.yml" -o -name "*.yaml" | xargs ansible-review-filtered.sh args: chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review-filtered.sh b/ci/ansible-review-filtered.sh new file mode 100755 index 0000000..84d2206 --- /dev/null +++ b/ci/ansible-review-filtered.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Remove warnings on stderr about missing configuration and used default rules. + +SEDSCRIPT=' +0,/^WARN: No configuration file found at/{/^WARN: No configuration file found at/d;}; +1,/^WARN: Using example .* found at/{/^WARN: Using example .* found at/d;}; +' + +exec ansible-review "$@" 2> >(sed -e "$SEDSCRIPT" >&2) From a8caeb67fcdc35a6876f1d2ba04459cc770557e4 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: May 12 2020 11:49:50 +0000 Subject: [PATCH 5/8] Zuul: Compartmentalize ansible-review crashes Some issues in playbooks and roles make ansible-review crash, therefore run it against every file individually. Signed-off-by: Nils Philippsen --- diff --git a/ci/ansible-review-everything.yaml b/ci/ansible-review-everything.yaml index 8ba40d7..1d1914f 100644 --- a/ci/ansible-review-everything.yaml +++ b/ci/ansible-review-everything.yaml @@ -1,11 +1,11 @@ - hosts: all tasks: - - name: Run ansible-review on the playbooks - shell: find playbooks -name "*.yml" -o -name "*.yaml" | xargs ansible-review-filtered.sh - args: - chdir: '{{ zuul.project.src_dir }}' - - - name: Run ansible-review on the roles - shell: find roles -name "*.yml" -o -name "*.yaml" | xargs ansible-review-filtered.sh + - name: Run ansible-review on the playbooks and roles + shell: > + exitcode=0; + while read pbrulefile; do + ansible-review-filtered.sh "$pbrulefile" || exitcode=1; + done <<<$(find playbooks roles -name "*.yml" -o -name "*.yaml"); + exit "$exitcode" args: chdir: '{{ zuul.project.src_dir }}' From c57609a6b6df698335032d11f57130753c86ff92 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 12 2020 11:49:59 +0000 Subject: [PATCH 6/8] Fix some problems found by ansible-review. Signed-off-by: Pierre-Yves Chibon Signed-off-by: Nils Philippsen --- diff --git a/playbooks/bridgeify.yml b/playbooks/bridgeify.yml index 29cbc11..5641ddf 100644 --- a/playbooks/bridgeify.yml +++ b/playbooks/bridgeify.yml @@ -23,7 +23,7 @@ - fedoraproject.org dhcp4: no auto6: no - autoconnect: yes + - name: br0-port0 state: up type: ethernet diff --git a/playbooks/manual/copr/copr-backend-upgrade.yml b/playbooks/manual/copr/copr-backend-upgrade.yml index 64bec64..9825e89 100644 --- a/playbooks/manual/copr/copr-backend-upgrade.yml +++ b/playbooks/manual/copr/copr-backend-upgrade.yml @@ -29,7 +29,6 @@ dnf: state=latest name=createrepo_c enablerepo=updates-testing - when: when: ansible_facts.packages['createrepo_c'][0].version is version('0.15.5', '<') handlers: From 11fb538e78939a7988c041312d57c399e9f6c5cb Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: May 13 2020 12:44:17 +0000 Subject: [PATCH 7/8] change path --- diff --git a/.zuul.yaml b/.zuul.yaml index 45126d7..1564795 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,16 +1,16 @@ - job: name: ansible-review-base - pre-run: ci/ansible-review-base.yaml + pre-run: ansible-review-base.yaml - job: name: ansible-review-everything parent: ansible-review-base - run: ci/ansible-review-everything.yaml + run: ansible-review-everything.yaml - job: name: ansible-review-diff parent: ansible-review-base - run: ci/ansible-review-diff.yaml + run: ansible-review-diff.yaml - project: check: diff --git a/ansible-review-base.yaml b/ansible-review-base.yaml new file mode 100644 index 0000000..eddbd2d --- /dev/null +++ b/ansible-review-base.yaml @@ -0,0 +1,14 @@ +- hosts: all + tasks: + - name: Install ansible-review + package: + name: python3-ansible-review + state: latest + + - name: Install invocation script + copy: + src: ansible-review-filtered.sh + dest: /usr/local/bin/ansible-review-filtered.sh + owner: root + group: root + mode: '0755' diff --git a/ansible-review-diff.yaml b/ansible-review-diff.yaml new file mode 100644 index 0000000..a56d8e4 --- /dev/null +++ b/ansible-review-diff.yaml @@ -0,0 +1,8 @@ +- hosts: all + tasks: + - name: Run ansible-review on the changes in the PR + shell: > + git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} + | ansible-review-filtered.sh + args: + chdir: '{{ zuul.project.src_dir }}' diff --git a/ansible-review-everything.yaml b/ansible-review-everything.yaml new file mode 100644 index 0000000..1d1914f --- /dev/null +++ b/ansible-review-everything.yaml @@ -0,0 +1,11 @@ +- hosts: all + tasks: + - name: Run ansible-review on the playbooks and roles + shell: > + exitcode=0; + while read pbrulefile; do + ansible-review-filtered.sh "$pbrulefile" || exitcode=1; + done <<<$(find playbooks roles -name "*.yml" -o -name "*.yaml"); + exit "$exitcode" + args: + chdir: '{{ zuul.project.src_dir }}' diff --git a/ansible-review-filtered.sh b/ansible-review-filtered.sh new file mode 100755 index 0000000..84d2206 --- /dev/null +++ b/ansible-review-filtered.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Remove warnings on stderr about missing configuration and used default rules. + +SEDSCRIPT=' +0,/^WARN: No configuration file found at/{/^WARN: No configuration file found at/d;}; +1,/^WARN: Using example .* found at/{/^WARN: Using example .* found at/d;}; +' + +exec ansible-review "$@" 2> >(sed -e "$SEDSCRIPT" >&2) diff --git a/ci/ansible-review-base.yaml b/ci/ansible-review-base.yaml deleted file mode 100644 index eddbd2d..0000000 --- a/ci/ansible-review-base.yaml +++ /dev/null @@ -1,14 +0,0 @@ -- hosts: all - tasks: - - name: Install ansible-review - package: - name: python3-ansible-review - state: latest - - - name: Install invocation script - copy: - src: ansible-review-filtered.sh - dest: /usr/local/bin/ansible-review-filtered.sh - owner: root - group: root - mode: '0755' diff --git a/ci/ansible-review-diff.yaml b/ci/ansible-review-diff.yaml deleted file mode 100644 index a56d8e4..0000000 --- a/ci/ansible-review-diff.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- hosts: all - tasks: - - name: Run ansible-review on the changes in the PR - shell: > - git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} - | ansible-review-filtered.sh - args: - chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review-everything.yaml b/ci/ansible-review-everything.yaml deleted file mode 100644 index 1d1914f..0000000 --- a/ci/ansible-review-everything.yaml +++ /dev/null @@ -1,11 +0,0 @@ -- hosts: all - tasks: - - name: Run ansible-review on the playbooks and roles - shell: > - exitcode=0; - while read pbrulefile; do - ansible-review-filtered.sh "$pbrulefile" || exitcode=1; - done <<<$(find playbooks roles -name "*.yml" -o -name "*.yaml"); - exit "$exitcode" - args: - chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review-filtered.sh b/ci/ansible-review-filtered.sh deleted file mode 100755 index 84d2206..0000000 --- a/ci/ansible-review-filtered.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Remove warnings on stderr about missing configuration and used default rules. - -SEDSCRIPT=' -0,/^WARN: No configuration file found at/{/^WARN: No configuration file found at/d;}; -1,/^WARN: Using example .* found at/{/^WARN: Using example .* found at/d;}; -' - -exec ansible-review "$@" 2> >(sed -e "$SEDSCRIPT" >&2) From 0219387e65cc0eed2abea2c3c5634d96f182e3bb Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: May 13 2020 13:41:36 +0000 Subject: [PATCH 8/8] Revert "change path" This reverts commit 11fb538e78939a7988c041312d57c399e9f6c5cb. --- diff --git a/.zuul.yaml b/.zuul.yaml index 1564795..45126d7 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,16 +1,16 @@ - job: name: ansible-review-base - pre-run: ansible-review-base.yaml + pre-run: ci/ansible-review-base.yaml - job: name: ansible-review-everything parent: ansible-review-base - run: ansible-review-everything.yaml + run: ci/ansible-review-everything.yaml - job: name: ansible-review-diff parent: ansible-review-base - run: ansible-review-diff.yaml + run: ci/ansible-review-diff.yaml - project: check: diff --git a/ansible-review-base.yaml b/ansible-review-base.yaml deleted file mode 100644 index eddbd2d..0000000 --- a/ansible-review-base.yaml +++ /dev/null @@ -1,14 +0,0 @@ -- hosts: all - tasks: - - name: Install ansible-review - package: - name: python3-ansible-review - state: latest - - - name: Install invocation script - copy: - src: ansible-review-filtered.sh - dest: /usr/local/bin/ansible-review-filtered.sh - owner: root - group: root - mode: '0755' diff --git a/ansible-review-diff.yaml b/ansible-review-diff.yaml deleted file mode 100644 index a56d8e4..0000000 --- a/ansible-review-diff.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- hosts: all - tasks: - - name: Run ansible-review on the changes in the PR - shell: > - git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} - | ansible-review-filtered.sh - args: - chdir: '{{ zuul.project.src_dir }}' diff --git a/ansible-review-everything.yaml b/ansible-review-everything.yaml deleted file mode 100644 index 1d1914f..0000000 --- a/ansible-review-everything.yaml +++ /dev/null @@ -1,11 +0,0 @@ -- hosts: all - tasks: - - name: Run ansible-review on the playbooks and roles - shell: > - exitcode=0; - while read pbrulefile; do - ansible-review-filtered.sh "$pbrulefile" || exitcode=1; - done <<<$(find playbooks roles -name "*.yml" -o -name "*.yaml"); - exit "$exitcode" - args: - chdir: '{{ zuul.project.src_dir }}' diff --git a/ansible-review-filtered.sh b/ansible-review-filtered.sh deleted file mode 100755 index 84d2206..0000000 --- a/ansible-review-filtered.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# Remove warnings on stderr about missing configuration and used default rules. - -SEDSCRIPT=' -0,/^WARN: No configuration file found at/{/^WARN: No configuration file found at/d;}; -1,/^WARN: Using example .* found at/{/^WARN: Using example .* found at/d;}; -' - -exec ansible-review "$@" 2> >(sed -e "$SEDSCRIPT" >&2) diff --git a/ci/ansible-review-base.yaml b/ci/ansible-review-base.yaml new file mode 100644 index 0000000..eddbd2d --- /dev/null +++ b/ci/ansible-review-base.yaml @@ -0,0 +1,14 @@ +- hosts: all + tasks: + - name: Install ansible-review + package: + name: python3-ansible-review + state: latest + + - name: Install invocation script + copy: + src: ansible-review-filtered.sh + dest: /usr/local/bin/ansible-review-filtered.sh + owner: root + group: root + mode: '0755' diff --git a/ci/ansible-review-diff.yaml b/ci/ansible-review-diff.yaml new file mode 100644 index 0000000..a56d8e4 --- /dev/null +++ b/ci/ansible-review-diff.yaml @@ -0,0 +1,8 @@ +- hosts: all + tasks: + - name: Run ansible-review on the changes in the PR + shell: > + git diff origin/{{ zuul.branch|quote }}...{{ zuul.branch|quote }} + | ansible-review-filtered.sh + args: + chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review-everything.yaml b/ci/ansible-review-everything.yaml new file mode 100644 index 0000000..1d1914f --- /dev/null +++ b/ci/ansible-review-everything.yaml @@ -0,0 +1,11 @@ +- hosts: all + tasks: + - name: Run ansible-review on the playbooks and roles + shell: > + exitcode=0; + while read pbrulefile; do + ansible-review-filtered.sh "$pbrulefile" || exitcode=1; + done <<<$(find playbooks roles -name "*.yml" -o -name "*.yaml"); + exit "$exitcode" + args: + chdir: '{{ zuul.project.src_dir }}' diff --git a/ci/ansible-review-filtered.sh b/ci/ansible-review-filtered.sh new file mode 100755 index 0000000..84d2206 --- /dev/null +++ b/ci/ansible-review-filtered.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Remove warnings on stderr about missing configuration and used default rules. + +SEDSCRIPT=' +0,/^WARN: No configuration file found at/{/^WARN: No configuration file found at/d;}; +1,/^WARN: Using example .* found at/{/^WARN: Using example .* found at/d;}; +' + +exec ansible-review "$@" 2> >(sed -e "$SEDSCRIPT" >&2)