diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..b653445 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,110 @@ +local AnsibleVersions(version="latest", package="ansible") = { + name: "ansible-" + version, + image: "python:3.7", + pull: "always", + environment: { + PY_COLORS: 1 + }, + commands: [ + "pip install " + package + " ansible-later~=0.2.0 -qq", + "git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy", + "ansible-later -c ~/policy/config.yml" + ], + depends_on: [ + "clone", + ], +}; + +local PipelineLinting = { + kind: "pipeline", + name: "linting", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + AnsibleVersions(version="latest", package="ansible"), + AnsibleVersions(version="master", package="git+https://github.com/ansible/ansible.git@devel"), + ], + trigger: { + ref: ["refs/heads/master", "refs/tags/**", "refs/pull/**"], + }, +}; + +local PipelineDeployment = { + kind: "pipeline", + name: "deployment", + platform: { + os: "linux", + arch: "amd64", + }, + workspace: { + base: "/drone/src", + path: "xoxys.nginx" + }, + steps: [ + { + name: "molecule", + image: "xoxys/molecule:gce-linux-amd64", + pull: "always", + environment: { + GCE_SSH_KEY: { "from_secret": "gce_ssh_key" }, + GCE_SERVICE_ACCOUNT_EMAIL: { "from_secret": "gce_service_account_email" }, + GCE_PROJECT_ID: { "from_secret": "gce_project_id" }, + GCE_CREDENTIALS_JSON: { "from_secret": "gce_credentials_json" }, + GCE_SSH_USER: { "from_secret": "gce_ssh_user" }, + GCE_CREDENTIALS_FILE: "/root/ansible-testing.json", + MOLECULE_CUSTOM_MODULES_REPO: "https://gitea.rknet.org/ansible/custom_modules", + PY_COLORS: 1 + }, + commands: [ + "/bin/bash /docker-entrypoint.sh", + "molecule create --scenario-name gce-centos-7", + "molecule converge --scenario-name gce-centos-7", + "molecule verify --scenario-name gce-centos-7", + "molecule destroy --scenario-name gce-centos-7", + ], + }, + ], + depends_on: [ + "linting", + ], + trigger: { + ref: ["refs/heads/master", "refs/tags/**"], + }, +}; + +local PipelineNotifications = { + kind: "pipeline", + name: "notifications", + platform: { + os: "linux", + arch: "amd64", + }, + steps: [ + { + name: "matrix", + image: "plugins/matrix", + settings: { + homeserver: "https://matrix.rknet.org", + roomid: "MtidqQXWWAtQcByBhH:rknet.org", + template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}", + username: { "from_secret": "matrix_username" }, + password: { "from_secret": "matrix_password" }, + }, + }, + ], + depends_on: [ + "deployment", + ], + trigger: { + status: [ "success", "failure" ], + ref: ["refs/heads/master", "refs/tags/**"], + }, +}; + +[ + PipelineLinting, + PipelineDeployment, + PipelineNotifications, +] diff --git a/.drone.yml b/.drone.yml index 53d816a..4f50ebe 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,42 +1,116 @@ --- kind: pipeline -name: default +name: linting + +platform: + os: linux + arch: amd64 steps: - - name: ansible-latest - image: python:2.7 - pull: always - commands: - - pip install ansible ansible-later -q - - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy - - git ls-files *[^LICENSE,.md] | xargs ansible-later -c ~/policy/config.ini - depends_on: - - clone +- name: ansible-latest + pull: always + image: python:3.7 + commands: + - pip install ansible ansible-later~=0.2.0 -qq + - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy + - ansible-later -c ~/policy/config.yml + environment: + PY_COLORS: 1 + depends_on: + - clone - - name: ansible-master - image: python:2.7 - pull: always - commands: - - pip install ansible ansible-later -q - - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy - - git ls-files *[^LICENSE,.md] | xargs ansible-later -c ~/policy/config.ini - depends_on: - - clone +- name: ansible-master + pull: always + image: python:3.7 + commands: + - "pip install git+https://github.com/ansible/ansible.git@devel ansible-later~=0.2.0 -qq" + - git clone https://gitea.rknet.org/ansible/ansible-later-policy.git ~/policy + - ansible-later -c ~/policy/config.yml + environment: + PY_COLORS: 1 + depends_on: + - clone - - name: notify - image: plugins/matrix - settings: - homeserver: https://matrix.rknet.org - roomid: MtidqQXWWAtQcByBhH:rknet.org - template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}" - username: - from_secret: matrix_username - password: - from_secret: matrix_password - depends_on: - - ansible-latest - - ansible-master - when: - status: - - success - - failure +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + - "refs/pull/**" + +--- +kind: pipeline +name: deployment + +platform: + os: linux + arch: amd64 + +workspace: + base: /drone/src + path: xoxys.nginx + +steps: +- name: molecule + pull: always + image: xoxys/molecule:gce-linux-amd64 + commands: + - /bin/bash /docker-entrypoint.sh + - molecule create --scenario-name gce-centos-7 + - molecule converge --scenario-name gce-centos-7 + - molecule verify --scenario-name gce-centos-7 + - molecule destroy --scenario-name gce-centos-7 + environment: + GCE_CREDENTIALS_FILE: /root/ansible-testing.json + GCE_CREDENTIALS_JSON: + from_secret: gce_credentials_json + GCE_PROJECT_ID: + from_secret: gce_project_id + GCE_SERVICE_ACCOUNT_EMAIL: + from_secret: gce_service_account_email + GCE_SSH_KEY: + from_secret: gce_ssh_key + GCE_SSH_USER: + from_secret: gce_ssh_user + MOLECULE_CUSTOM_MODULES_REPO: https://gitea.rknet.org/ansible/custom_modules + PY_COLORS: 1 + +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + +depends_on: +- linting + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +steps: +- name: matrix + image: plugins/matrix + settings: + homeserver: https://matrix.rknet.org + password: + from_secret: matrix_password + roomid: MtidqQXWWAtQcByBhH:rknet.org + template: "Status: **{{ build.status }}**
Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}
Message: {{ build.message }}" + username: + from_secret: matrix_username + +trigger: + ref: + - refs/heads/master + - "refs/tags/**" + status: + - success + - failure + +depends_on: +- deployment + +...