From 0e7dee1beb6c5809bb3e53c0b52f59226ce98b05 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sun, 20 Jan 2019 20:45:25 +0100 Subject: [PATCH 01/14] Move dockerfiles to docker folder --- Dockerfile.i386 | 12 ------------ Dockerfile => docker/Dockerfile.linux.amd64 | 2 +- Dockerfile.arm => docker/Dockerfile.linux.arm | 2 +- Dockerfile.arm64 => docker/Dockerfile.linux.arm64 | 2 +- .../Dockerfile.windows.amd64 | 4 +--- 5 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 Dockerfile.i386 rename Dockerfile => docker/Dockerfile.linux.amd64 (94%) rename Dockerfile.arm => docker/Dockerfile.linux.arm (93%) rename Dockerfile.arm64 => docker/Dockerfile.linux.arm64 (92%) rename Dockerfile.windows => docker/Dockerfile.windows.amd64 (68%) diff --git a/Dockerfile.i386 b/Dockerfile.i386 deleted file mode 100644 index e0306c4..0000000 --- a/Dockerfile.i386 +++ /dev/null @@ -1,12 +0,0 @@ -FROM plugins/base:i386 - -LABEL maintainer="Drone.IO Community " \ - org.label-schema.name="Drone Ansible" \ - org.label-schema.vendor="Drone.IO Community" \ - org.label-schema.schema-version="1.0" - -RUN apk add --no-cache bash git curl rysnc openssh-client ansible py-pip && \ - pip install -U pip - -ADD release/linux/i386/drone-ansible /bin/ -ENTRYPOINT ["/bin/drone-ansible"] diff --git a/Dockerfile b/docker/Dockerfile.linux.amd64 similarity index 94% rename from Dockerfile rename to docker/Dockerfile.linux.amd64 index d623a02..056a067 100644 --- a/Dockerfile +++ b/docker/Dockerfile.linux.amd64 @@ -1,4 +1,4 @@ -FROM plugins/base:amd64 +FROM plugins/base:linux-amd64 LABEL maintainer="Drone.IO Community " \ org.label-schema.name="Drone Ansible" \ diff --git a/Dockerfile.arm b/docker/Dockerfile.linux.arm similarity index 93% rename from Dockerfile.arm rename to docker/Dockerfile.linux.arm index 4e8c2d4..f51fa75 100644 --- a/Dockerfile.arm +++ b/docker/Dockerfile.linux.arm @@ -1,4 +1,4 @@ -FROM plugins/base:arm +FROM plugins/base:linux-arm LABEL maintainer="Drone.IO Community " \ org.label-schema.name="Drone Ansible" \ diff --git a/Dockerfile.arm64 b/docker/Dockerfile.linux.arm64 similarity index 92% rename from Dockerfile.arm64 rename to docker/Dockerfile.linux.arm64 index b1e9139..6c688e9 100644 --- a/Dockerfile.arm64 +++ b/docker/Dockerfile.linux.arm64 @@ -1,4 +1,4 @@ -FROM plugins/base:arm64 +FROM plugins/base:linux-arm64 LABEL maintainer="Drone.IO Community " \ org.label-schema.name="Drone Ansible" \ diff --git a/Dockerfile.windows b/docker/Dockerfile.windows.amd64 similarity index 68% rename from Dockerfile.windows rename to docker/Dockerfile.windows.amd64 index 79040e9..fb01d66 100644 --- a/Dockerfile.windows +++ b/docker/Dockerfile.windows.amd64 @@ -1,13 +1,11 @@ # escape=` -FROM microsoft/nanoserver:10.0.14393.1593 +FROM plugins/base:windows-amd64 LABEL maintainer="Drone.IO Community " ` org.label-schema.name="Drone Ansible" ` org.label-schema.vendor="Drone.IO Community" ` org.label-schema.schema-version="1.0" -SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] - # TODO: install required tools ADD release\drone-ansible.exe c:\drone-ansible.exe From bfd1e312f82b80f1518886dc245c32e5bb4b1a20 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sun, 20 Jan 2019 22:21:23 +0100 Subject: [PATCH 02/14] Add manifest template to docker folder --- manifest.tmpl => docker/manifest.tmpl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename manifest.tmpl => docker/manifest.tmpl (84%) diff --git a/manifest.tmpl b/docker/manifest.tmpl similarity index 84% rename from manifest.tmpl rename to docker/manifest.tmpl index 8443387..04eef14 100644 --- a/manifest.tmpl +++ b/docker/manifest.tmpl @@ -11,23 +11,21 @@ manifests: platform: architecture: amd64 os: linux - - - image: plugins/ansible:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-i386 - platform: - architecture: 386 - os: linux - image: plugins/ansible:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64 platform: architecture: arm64 os: linux + variant: v8 - image: plugins/ansible:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm platform: architecture: arm os: linux + variant: v7 - image: plugins/ansible:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}windows-amd64 platform: architecture: amd64 os: windows + variant: 1809 From bbcc572d481817938d574f06d97c3294bc76fde3 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Sun, 20 Jan 2019 23:51:58 +0100 Subject: [PATCH 03/14] Migrate configs to drone 1.0.0 and drop appveyor --- .appveyor.yml | 66 -------- .drone.jsonnet | 161 ++++++++++++++++++ .drone.windows.yml | 70 ++++++++ .drone.yml | 408 ++++++++++++++++++++++++++++++--------------- 4 files changed, 507 insertions(+), 198 deletions(-) delete mode 100644 .appveyor.yml create mode 100644 .drone.jsonnet create mode 100644 .drone.windows.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 5bfa10a..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,66 +0,0 @@ -version: '{build}' -image: 'Visual Studio 2017' -platform: 'x64' - -clone_folder: 'c:\gopath\src\github.com\drone-plugins\drone-ansible' -max_jobs: 1 - -environment: - GOPATH: c:\gopath - DOCKER_USERNAME: - secure: '4YzzahbEiMZQJpOCOd1LAw==' - DOCKER_PASSWORD: - secure: 'VqO/G3Zfslu6zSLdwHKO+Q==' - GO111MODULE: on - -install: - - ps: | - docker version - go version - - ps: | - $env:Path = "c:\gopath\bin;$env:Path" - -build_script: - - ps: | - if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) { - go build -ldflags "-X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-ansible.exe - } else { - $version = $env:APPVEYOR_REPO_TAG_NAME.substring(1) - go build -ldflags "-X main.version=$version -X main.build=$env:APPVEYOR_BUILD_VERSION" -a -o release/drone-ansible.exe - } - - docker pull microsoft/nanoserver:10.0.14393.1593 - docker build -f Dockerfile.windows -t plugins/ansible:windows-amd64 . - -test_script: - - ps: | - docker run --rm plugins/ansible:windows-amd64 --version - -deploy_script: - - ps: | - $ErrorActionPreference = 'Stop'; - - if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) { - Write-Host Nothing to deploy. - } else { - echo $env:DOCKER_PASSWORD | docker login --username $env:DOCKER_USERNAME --password-stdin - - if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) { - $major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.') - - docker push plugins/ansible:windows-amd64 - - docker tag plugins/ansible:windows-amd64 plugins/ansible:$major.$minor.$patch-windows-amd64 - docker push plugins/ansible:$major.$minor.$patch-windows-amd64 - - docker tag plugins/ansible:windows-amd64 plugins/ansible:$major.$minor-windows-amd64 - docker push plugins/ansible:$major.$minor-windows-amd64 - - docker tag plugins/ansible:windows-amd64 plugins/ansible:$major-windows-amd64 - docker push plugins/ansible:$major-windows-amd64 - } else { - if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) { - docker push plugins/ansible:windows-amd64 - } - } - } diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..5de825a --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,161 @@ +local PipelineTesting = { + kind: "pipeline", + name: "testing", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + { + name: "vet", + image: "golang:1.11", + pull: "always", + environment: { + GO111MODULE: "on", + }, + commands: [ + "go vet ./...", + ], + }, + { + name: "test", + image: "golang:1.11", + pull: "always", + environment: { + GO111MODULE: "on", + }, + commands: [ + "go test -cover ./...", + ], + }, + ], + trigger: { + branch: [ "master" ], + }, +}; + +local PipelineBuild(os="linux", arch="amd64") = { + kind: "pipeline", + name: os + "-" + arch, + platform: { + os: os, + arch: arch, + }, + steps: [ + { + name: "build", + image: "golang:1.11", + pull: "always", + environment: { + CGO_ENABLED: "0", + GO111MODULE: "on", + }, + commands: [ + "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-ansible", + ], + when: { + event: [ "push", "pull_request" ], + }, + }, + { + name: "build", + image: "golang:1.11", + pull: "always", + environment: { + CGO_ENABLED: "0", + GO111MODULE: "on", + }, + commands: [ + "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-ansible", + ], + when: { + event: [ "tag" ], + }, + }, + { + name: "dryrun", + image: "plugins/docker:" + os + "-" + arch, + pull: "always", + settings: { + dry_run: true, + tags: os + "-" + arch, + dockerfile: "docker/Dockerfile." + os + "." + arch, + repo: "plugins/ansible", + username: { "from_secret": "docker_username" }, + password: { "from_secret": "docker_password" }, + }, + when: { + event: [ "pull_request" ], + }, + }, + { + name: "publish", + image: "plugins/docker:" + os + "-" + arch, + pull: "always", + settings: { + auto_tag: true, + auto_tag_suffix: os + "-" + arch, + dockerfile: "docker/Dockerfile." + os + "." + arch, + repo: "plugins/ansible", + username: { "from_secret": "docker_username" }, + password: { "from_secret": "docker_password" }, + }, + when: { + event: [ "push", "tag" ], + }, + }, + ], + depends_on: [ + "testing", + ], + trigger: { + branch: [ "master" ], + }, +}; + +local PipelineNotifications = { + kind: "pipeline", + name: "notifications", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + { + name: "manifest", + image: "plugins/manifest:1", + pull: "always", + settings: { + username: { "from_secret": "docker_username" }, + password: { "from_secret": "docker_password" }, + spec: "docker/manifest.tmpl", + ignore_missing: true, + }, + }, + { + name: "microbadger", + image: "plugins/webhook:1", + pull: "always", + settings: { + url: { "from_secret": "microbadger_url" }, + }, + }, + ], + depends_on: [ + "linux-amd64", + "linux-arm64", + "linux-arm", + ], + trigger: { + branch: [ "master" ], + event: [ "push", "tag" ], + }, +}; + +[ + PipelineTesting, + PipelineBuild("linux", "amd64"), + PipelineBuild("linux", "arm64"), + PipelineBuild("linux", "arm"), + PipelineNotifications, +] diff --git a/.drone.windows.yml b/.drone.windows.yml new file mode 100644 index 0000000..55a2139 --- /dev/null +++ b/.drone.windows.yml @@ -0,0 +1,70 @@ +--- +kind: pipeline +name: linux-amd64 + +platform: + os: linux + arch: amd64 + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-amd64 + settings: + dockerfile: docker/Dockerfile.linux.amd64 + dry_run: true + password: + from_secret: docker_password + repo: plugins/ansible + tags: linux-amd64 + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-amd64 + settings: + auto_tag: true + auto_tag_suffix: linux-amd64 + dockerfile: docker/Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag + +trigger: + branch: + - master diff --git a/.drone.yml b/.drone.yml index 3f2ac21..d0a07d9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,147 +1,291 @@ -workspace: - base: /go - path: src/github.com/drone-plugins/drone-ansible +--- +kind: pipeline +name: testing -pipeline: - test: - image: golang:1.11 - pull: true - environment: - - GO111MODULE=on - commands: - - go vet ./... - - go test -cover ./... +platform: + os: linux + arch: amd64 - build_linux_amd64: - image: golang:1.11 - pull: true - group: build - environment: - - GOOS=linux - - GOARCH=amd64 - - CGO_ENABLED=0 - - GO111MODULE=on - commands: - - | - if test "${DRONE_TAG}" = ""; then - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-ansible - else - go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-ansible - fi +steps: +- name: vet + pull: always + image: golang:1.11 + commands: + - go vet ./... + environment: + GO111MODULE: on - # build_linux_i386: - # image: golang:1.11 - # pull: true - # group: build - # environment: - # - GOOS=linux - # - GOARCH=386 - # - CGO_ENABLED=0 - # - GO111MODULE=on - # commands: - # - | - # if test "${DRONE_TAG}" = ""; then - # go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-ansible - # else - # go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/i386/drone-ansible - # fi +- name: test + pull: always + image: golang:1.11 + commands: + - go test -cover ./... + environment: + GO111MODULE: on - # build_linux_arm64: - # image: golang:1.11 - # pull: true - # group: build - # environment: - # - GOOS=linux - # - GOARCH=arm64 - # - CGO_ENABLED=0 - # - GO111MODULE=on - # commands: - # - | - # if test "${DRONE_TAG}" = ""; then - # go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-ansible - # else - # go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-ansible - # fi +trigger: + branch: + - master - # build_linux_arm: - # image: golang:1.11 - # pull: true - # group: build - # environment: - # - GOOS=linux - # - GOARCH=arm - # - CGO_ENABLED=0 - # - GOARM=7 - # - GO111MODULE=on - # commands: - # - | - # if test "${DRONE_TAG}" = ""; then - # go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-ansible - # else - # go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-ansible - # fi +--- +kind: pipeline +name: linux-amd64 - publish_linux_amd64: - image: plugins/docker:17.12 - pull: true - secrets: [ docker_username, docker_password ] - group: docker +platform: + os: linux + arch: amd64 + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-amd64 + settings: + dockerfile: docker/Dockerfile.linux.amd64 + dry_run: true + password: + from_secret: docker_password repo: plugins/ansible + tags: linux-amd64 + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-amd64 + settings: auto_tag: true auto_tag_suffix: linux-amd64 - dockerfile: Dockerfile - when: - event: [ push, tag ] + dockerfile: docker/Dockerfile.linux.amd64 + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag - # publish_linux_i386: - # image: plugins/docker:17.12 - # pull: true - # secrets: [ docker_username, docker_password ] - # group: docker - # repo: plugins/ansible - # auto_tag: true - # auto_tag_suffix: linux-i386 - # dockerfile: Dockerfile.i386 - # when: - # event: [ push, tag ] +trigger: + branch: + - master - # publish_linux_arm64: - # image: plugins/docker:17.12 - # pull: true - # secrets: [ docker_username, docker_password ] - # group: docker - # repo: plugins/ansible - # auto_tag: true - # auto_tag_suffix: linux-arm64 - # dockerfile: Dockerfile.arm64 - # when: - # event: [ push, tag ] +depends_on: +- testing - # publish_linux_arm: - # image: plugins/docker:17.12 - # pull: true - # secrets: [ docker_username, docker_password ] - # group: docker - # repo: plugins/ansible - # auto_tag: true - # auto_tag_suffix: linux-arm - # dockerfile: Dockerfile.arm - # when: - # event: [ push, tag ] +--- +kind: pipeline +name: linux-arm64 - manifests: - image: plugins/manifest:1 - pull: true - secrets: [ docker_username, docker_password ] - spec: manifest.tmpl +platform: + os: linux + arch: arm64 + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-arm64 + settings: + dockerfile: docker/Dockerfile.linux.arm64 + dry_run: true + password: + from_secret: docker_password + repo: plugins/ansible + tags: linux-arm64 + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-arm64 + settings: auto_tag: true - ignore_missing: true - when: - event: [ push, tag ] + auto_tag_suffix: linux-arm64 + dockerfile: docker/Dockerfile.linux.arm64 + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag - microbadger: - image: plugins/webhook:1 - pull: true - secrets: [ webhook_url ] - when: - status: [ success ] +trigger: + branch: + - master + +depends_on: +- testing + +--- +kind: pipeline +name: linux-arm + +platform: + os: linux + arch: arm + +steps: +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - push + - pull_request + +- name: build + pull: always + image: golang:1.11 + commands: + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-ansible" + environment: + CGO_ENABLED: 0 + GO111MODULE: on + when: + event: + - tag + +- name: dryrun + pull: always + image: plugins/docker:linux-arm + settings: + dockerfile: docker/Dockerfile.linux.arm + dry_run: true + password: + from_secret: docker_password + repo: plugins/ansible + tags: linux-arm + username: + from_secret: docker_username + when: + event: + - pull_request + +- name: publish + pull: always + image: plugins/docker:linux-arm + settings: + auto_tag: true + auto_tag_suffix: linux-arm + dockerfile: docker/Dockerfile.linux.arm + password: + from_secret: docker_password + repo: plugins/ansible + username: + from_secret: docker_username + when: + event: + - push + - tag + +trigger: + branch: + - master + +depends_on: +- testing + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +steps: +- name: manifest + pull: always + image: plugins/manifest:1 + settings: + ignore_missing: true + password: + from_secret: docker_password + spec: docker/manifest.tmpl + username: + from_secret: docker_username + +- name: microbadger + pull: always + image: plugins/webhook:1 + settings: + url: + from_secret: microbadger_url + +trigger: + branch: + - master + event: + - push + - tag + +depends_on: +- linux-amd64 +- linux-arm64 +- linux-arm + +... From 16554b6e7fc9035f4fb2b2e3a2568ad100224743 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 00:19:14 +0100 Subject: [PATCH 04/14] Update badges within readme --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0fc21a8..90da7e2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # drone-ansible -[![Build Status](http://beta.drone.io/api/badges/drone-plugins/drone-ansible/status.svg)](http://beta.drone.io/drone-plugins/drone-ansible) -[![Join the discussion at https://www.reddit.com/r/droneci/](https://img.shields.io/badge/reddit-forum-orange.svg)](https://www.reddit.com/r/droneci/) +[![Build Status](http://cloud.drone.io/api/badges/drone-plugins/drone-ansible/status.svg)](http://cloud.drone.io/drone-plugins/drone-ansible) +[![Gitter chat](https://badges.gitter.im/drone/drone.png)](https://gitter.im/drone/drone) +[![Join the discussion at https://discourse.drone.io](https://img.shields.io/badge/discourse-forum-orange.svg)](https://discourse.drone.io) [![Drone questions at https://stackoverflow.com](https://img.shields.io/badge/drone-stackoverflow-orange.svg)](https://stackoverflow.com/questions/tagged/drone.io) +[![](https://images.microbadger.com/badges/image/plugins/ansible.svg)](https://microbadger.com/images/plugins/ansible "Get your own image badge on microbadger.com") [![Go Doc](https://godoc.org/github.com/drone-plugins/drone-ansible?status.svg)](http://godoc.org/github.com/drone-plugins/drone-ansible) [![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-ansible)](https://goreportcard.com/report/github.com/drone-plugins/drone-ansible) [![](https://images.microbadger.com/badges/image/plugins/ansible.svg)](https://microbadger.com/images/plugins/ansible "Get your own image badge on microbadger.com") From 8acb5b5b8d4ac3848f5fd79a8101fc2ce6fca7c8 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 01:04:35 +0100 Subject: [PATCH 05/14] Fix duplicated step names --- .drone.jsonnet | 4 ++-- .drone.windows.yml | 20 ++++++++++---------- .drone.yml | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 5de825a..5b67fa3 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -43,7 +43,7 @@ local PipelineBuild(os="linux", arch="amd64") = { }, steps: [ { - name: "build", + name: "build-push", image: "golang:1.11", pull: "always", environment: { @@ -58,7 +58,7 @@ local PipelineBuild(os="linux", arch="amd64") = { }, }, { - name: "build", + name: "build-tag", image: "golang:1.11", pull: "always", environment: { diff --git a/.drone.windows.yml b/.drone.windows.yml index 55a2139..8ef4e56 100644 --- a/.drone.windows.yml +++ b/.drone.windows.yml @@ -1,9 +1,9 @@ --- kind: pipeline -name: linux-amd64 +name: windows-amd64 platform: - os: linux + os: windows arch: amd64 steps: @@ -11,7 +11,7 @@ steps: pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-ansible" environment: CGO_ENABLED: 0 GO111MODULE: on @@ -24,7 +24,7 @@ steps: pull: always image: golang:1.11 commands: - - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-ansible" + - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-ansible" environment: CGO_ENABLED: 0 GO111MODULE: on @@ -34,14 +34,14 @@ steps: - name: dryrun pull: always - image: plugins/docker:linux-amd64 + image: plugins/docker:windows-amd64 settings: - dockerfile: docker/Dockerfile.linux.amd64 + dockerfile: docker/Dockerfile.windows.amd64 dry_run: true password: from_secret: docker_password repo: plugins/ansible - tags: linux-amd64 + tags: windows-amd64 username: from_secret: docker_username when: @@ -50,11 +50,11 @@ steps: - name: publish pull: always - image: plugins/docker:linux-amd64 + image: plugins/docker:windows-amd64 settings: auto_tag: true - auto_tag_suffix: linux-amd64 - dockerfile: docker/Dockerfile.linux.amd64 + auto_tag_suffix: windows-amd64 + dockerfile: docker/Dockerfile.windows.amd64 password: from_secret: docker_password repo: plugins/ansible diff --git a/.drone.yml b/.drone.yml index d0a07d9..573cfae 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,7 +36,7 @@ platform: arch: amd64 steps: -- name: build +- name: build-push pull: always image: golang:1.11 commands: @@ -49,7 +49,7 @@ steps: - push - pull_request -- name: build +- name: build-tag pull: always image: golang:1.11 commands: @@ -110,7 +110,7 @@ platform: arch: arm64 steps: -- name: build +- name: build-push pull: always image: golang:1.11 commands: @@ -123,7 +123,7 @@ steps: - push - pull_request -- name: build +- name: build-tag pull: always image: golang:1.11 commands: @@ -184,7 +184,7 @@ platform: arch: arm steps: -- name: build +- name: build-push pull: always image: golang:1.11 commands: @@ -197,7 +197,7 @@ steps: - push - pull_request -- name: build +- name: build-tag pull: always image: golang:1.11 commands: From b415317dab861b3362c79bb0e3d10d0bda686bf8 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 09:31:24 +0100 Subject: [PATCH 06/14] Remove duplicated badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 90da7e2..bc167b2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![](https://images.microbadger.com/badges/image/plugins/ansible.svg)](https://microbadger.com/images/plugins/ansible "Get your own image badge on microbadger.com") [![Go Doc](https://godoc.org/github.com/drone-plugins/drone-ansible?status.svg)](http://godoc.org/github.com/drone-plugins/drone-ansible) [![Go Report](https://goreportcard.com/badge/github.com/drone-plugins/drone-ansible)](https://goreportcard.com/report/github.com/drone-plugins/drone-ansible) -[![](https://images.microbadger.com/badges/image/plugins/ansible.svg)](https://microbadger.com/images/plugins/ansible "Get your own image badge on microbadger.com") Drone plugin to provision infrastructure with [Ansible](https://www.ansible.com/). For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/drone-plugins/drone-ansible/). From ab9f8c5efe3ce5ea203082daf6249eef65eda374 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 15:56:33 +0100 Subject: [PATCH 07/14] Install fixed ansible version as on amd64 --- docker/Dockerfile.linux.arm | 5 +++-- docker/Dockerfile.linux.arm64 | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm index f51fa75..e676aa3 100644 --- a/docker/Dockerfile.linux.arm +++ b/docker/Dockerfile.linux.arm @@ -5,8 +5,9 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.vendor="Drone.IO Community" \ org.label-schema.schema-version="1.0" -RUN apk add --no-cache bash git curl rsync openssh-client ansible py-pip && \ - pip install -U pip +RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ + pip install -U pip ansible==2.6.3 && \ + apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/arm/drone-ansible /bin/ ENTRYPOINT ["/bin/drone-ansible"] diff --git a/docker/Dockerfile.linux.arm64 b/docker/Dockerfile.linux.arm64 index 6c688e9..f7bf032 100644 --- a/docker/Dockerfile.linux.arm64 +++ b/docker/Dockerfile.linux.arm64 @@ -5,8 +5,9 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.vendor="Drone.IO Community" \ org.label-schema.schema-version="1.0" -RUN apk add --no-cache bash git curl rsync openssh-client ansible py-pip && \ - pip install -U pip +RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ + pip install -U pip ansible==2.6.3 && \ + apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/arm64/drone-ansible /bin/ ENTRYPOINT ["/bin/drone-ansible"] From d91f2593619801a134c3599ed81a00afa4f286e7 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 15:59:11 +0100 Subject: [PATCH 08/14] Upgrade ansible to latest version --- docker/Dockerfile.linux.amd64 | 2 +- docker/Dockerfile.linux.arm | 2 +- docker/Dockerfile.linux.arm64 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.linux.amd64 b/docker/Dockerfile.linux.amd64 index 056a067..587da85 100644 --- a/docker/Dockerfile.linux.amd64 +++ b/docker/Dockerfile.linux.amd64 @@ -6,7 +6,7 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.schema-version="1.0" RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ - pip install -U pip ansible==2.6.3 && \ + pip install -U pip ansible==2.7.6 && \ apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/amd64/drone-ansible /bin/ diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm index e676aa3..2be58b4 100644 --- a/docker/Dockerfile.linux.arm +++ b/docker/Dockerfile.linux.arm @@ -6,7 +6,7 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.schema-version="1.0" RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ - pip install -U pip ansible==2.6.3 && \ + pip install -U pip ansible==2.7.6 && \ apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/arm/drone-ansible /bin/ diff --git a/docker/Dockerfile.linux.arm64 b/docker/Dockerfile.linux.arm64 index f7bf032..dd25f0e 100644 --- a/docker/Dockerfile.linux.arm64 +++ b/docker/Dockerfile.linux.arm64 @@ -6,7 +6,7 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.schema-version="1.0" RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ - pip install -U pip ansible==2.6.3 && \ + pip install -U pip ansible==2.7.6 && \ apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/arm64/drone-ansible /bin/ From 285c83f2a9c750b630951386224f0c14cfa74462 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 16:41:03 +0100 Subject: [PATCH 09/14] Separate pip upgrade from ansible install, install latest ansible version --- docker/Dockerfile.linux.amd64 | 3 ++- docker/Dockerfile.linux.arm | 3 ++- docker/Dockerfile.linux.arm64 | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.linux.amd64 b/docker/Dockerfile.linux.amd64 index 587da85..b926348 100644 --- a/docker/Dockerfile.linux.amd64 +++ b/docker/Dockerfile.linux.amd64 @@ -6,7 +6,8 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.schema-version="1.0" RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ - pip install -U pip ansible==2.7.6 && \ + pip install -U pip && \ + pip install ansible==2.7.6 && \ apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/amd64/drone-ansible /bin/ diff --git a/docker/Dockerfile.linux.arm b/docker/Dockerfile.linux.arm index 2be58b4..1e0390d 100644 --- a/docker/Dockerfile.linux.arm +++ b/docker/Dockerfile.linux.arm @@ -6,7 +6,8 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.schema-version="1.0" RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ - pip install -U pip ansible==2.7.6 && \ + pip install -U pip && \ + pip install ansible==2.7.6 && \ apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/arm/drone-ansible /bin/ diff --git a/docker/Dockerfile.linux.arm64 b/docker/Dockerfile.linux.arm64 index dd25f0e..3c9c3dc 100644 --- a/docker/Dockerfile.linux.arm64 +++ b/docker/Dockerfile.linux.arm64 @@ -6,7 +6,8 @@ LABEL maintainer="Drone.IO Community " \ org.label-schema.schema-version="1.0" RUN apk add --no-cache bash git curl rsync openssh-client py-pip py-requests python2-dev libffi-dev libressl-dev build-base && \ - pip install -U pip ansible==2.7.6 && \ + pip install -U pip && \ + pip install ansible==2.7.6 && \ apk del python2-dev libffi-dev libressl-dev build-base ADD release/linux/arm64/drone-ansible /bin/ From a5c0accc0ec4edda54a4e4331ecda8b0184ae2fe Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 20:55:48 +0100 Subject: [PATCH 10/14] Add probot settings config --- .github/settings.yml | 73 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/settings.yml diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..bcb3b12 --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,73 @@ +repository: + name: drone-ansible + description: Drone plugin to provision via Ansible + homepage: http://plugins.drone.io/drone-plugins/drone-ansible + topics: drone, drone-plugin + + private: false + has_issues: true + has_wiki: false + has_downloads: false + + default_branch: master + + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: true + +labels: + - name: bug + color: d73a4a + description: Something isn't working + - name: duplicate + color: cfd3d7 + description: This issue or pull request already exists + - name: enhancement + color: a2eeef + description: New feature or request + - name: good first issue + color: 7057ff + description: Good for newcomers + - name: help wanted + color: 008672 + description: Extra attention is needed + - name: invalid + color: e4e669 + description: This doesn't seem right + - name: question + color: d876e3 + description: Further information is requested + - name: renovate + color: e99695 + description: Automated action from Renovate + - name: wontfix + color: ffffff + description: This will not be worked on + +teams: + - name: Admins + permission: admin + - name: Captain + permission: admin + - name: Maintainers + permission: push + +branches: + - name: master + protection: + required_pull_request_reviews: + required_approving_review_count: 1 + dismiss_stale_reviews: false + require_code_owner_reviews: false + dismissal_restrictions: + teams: + - Admins + - Captain + required_status_checks: + strict: true + contexts: + - continuous-integration/drone/pr + enforce_admins: false + restrictions: + users: [] + teams: [] From 0246c7e05c4f8ade11998eb51d12914dbfe3674a Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 21 Jan 2019 21:02:07 +0100 Subject: [PATCH 11/14] Add some basic issue template content --- .github/issue_template.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/issue_template.md b/.github/issue_template.md index e69de29..3f95605 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -0,0 +1,9 @@ + From 7e171325ed0c60ddc57d7ba06d5eea2042afbbb8 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Tue, 22 Jan 2019 23:11:45 +0100 Subject: [PATCH 12/14] Execute built binary as simple test --- .drone.jsonnet | 8 ++++++++ .drone.windows.yml | 10 ++++++++-- .drone.yml | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 5b67fa3..debc762 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -72,6 +72,14 @@ local PipelineBuild(os="linux", arch="amd64") = { event: [ "tag" ], }, }, + { + name: "executable", + image: "golang:1.11", + pull: "always", + commands: [ + "./release/" + os + "/" + arch + "/drone-ansible --help", + ], + }, { name: "dryrun", image: "plugins/docker:" + os + "-" + arch, diff --git a/.drone.windows.yml b/.drone.windows.yml index 8ef4e56..c5d7c12 100644 --- a/.drone.windows.yml +++ b/.drone.windows.yml @@ -7,7 +7,7 @@ platform: arch: amd64 steps: -- name: build +- name: build-push pull: always image: golang:1.11 commands: @@ -20,7 +20,7 @@ steps: - push - pull_request -- name: build +- name: build-tag pull: always image: golang:1.11 commands: @@ -32,6 +32,12 @@ steps: event: - tag +- name: executable + pull: always + image: golang:1.11 + commands: + - ./release/windows/amd64/drone-ansible --help + - name: dryrun pull: always image: plugins/docker:windows-amd64 diff --git a/.drone.yml b/.drone.yml index 573cfae..95e4b9c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -61,6 +61,12 @@ steps: event: - tag +- name: executable + pull: always + image: golang:1.11 + commands: + - ./release/linux/amd64/drone-ansible --help + - name: dryrun pull: always image: plugins/docker:linux-amd64 @@ -135,6 +141,12 @@ steps: event: - tag +- name: executable + pull: always + image: golang:1.11 + commands: + - ./release/linux/arm64/drone-ansible --help + - name: dryrun pull: always image: plugins/docker:linux-arm64 @@ -209,6 +221,12 @@ steps: event: - tag +- name: executable + pull: always + image: golang:1.11 + commands: + - ./release/linux/arm/drone-ansible --help + - name: dryrun pull: always image: plugins/docker:linux-arm From 7967a923afafd5d9bd4c9d77b3b79d85d6f8cf3b Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Wed, 23 Jan 2019 09:47:09 +0100 Subject: [PATCH 13/14] Properly configure permissions for protected branches --- .github/settings.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/settings.yml b/.github/settings.yml index bcb3b12..a1e4d90 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -70,4 +70,6 @@ branches: enforce_admins: false restrictions: users: [] - teams: [] + teams: + - Admins + - Captain From d240638e3c666237ce4b9a87777977b615aeccac Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Wed, 23 Jan 2019 09:47:25 +0100 Subject: [PATCH 14/14] Export required env variables within readme --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bc167b2..0b47798 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,13 @@ Drone plugin to provision infrastructure with [Ansible](https://www.ansible.com/ Build the binary with the following commands: ``` -go build +export GOOS=linux +export GOARCH=amd64 +export CGO_ENABLED=0 +export GO111MODULE=on + +go test -cover ./... +go build -v -a -tags netgo -o release/linux/amd64/drone-ansible ``` ## Docker @@ -23,8 +29,10 @@ go build Build the Docker image with the following commands: ``` -GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-ansible -docker build --rm -t plugins/ansible . +docker build \ + --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ + --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \ + --file docker/Dockerfile.linux.amd64 --tag plugins/ansible . ``` ### Usage