From c64a9212f265aa29daf460379215983c615d99cc Mon Sep 17 00:00:00 2001 From: Noah Knegt Date: Thu, 30 Mar 2023 15:47:41 +0200 Subject: [PATCH 1/4] Add private key Signed-off-by: Noah Knegt --- .drone.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7f232d1..b97e996 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,14 +15,14 @@ steps: - ansible-lint . - name: ansible apply - image: plugins/ansible:3 - settings: - inventory: inventory/hosts.yml - playbook: site.yml - private_key: - from_secret: ansible_private_key - when: - branch: - - master - event: - - push + image: cytopia/ansible:alpine + volumes: + - name: ssh-keys + path: /root/.ssh/ + commands: + - ansible-playbook -i inventory/hosts site.yml --private-key /root/.ssh/id_ed25519 + +volumes: + - name: ssh-keys + host: + path: /home/ansible/.ssh/ -- 2.49.1 From 0c23539f18eccb6c0d6e2a76455278a24b2efc13 Mon Sep 17 00:00:00 2001 From: Noah Knegt Date: Fri, 31 Mar 2023 09:40:58 +0200 Subject: [PATCH 2/4] Generate the ssh key from secret in CI Signed-off-by: Noah Knegt --- .drone.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index b97e996..4c547bc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,15 +14,18 @@ steps: commands: - ansible-lint . + - name: setup ssh key + image: alpine:latest + commands: + - mkdir -p /drone/src/.ssh + - echo "$SSH_KEY" > /drone/src/.ssh/id_ed25519 + - chmod 600 /drone/src/.ssh/id_ed25519 + environment: + SSH_KEY: + from_secret: ssh_key + - name: ansible apply image: cytopia/ansible:alpine - volumes: - - name: ssh-keys - path: /root/.ssh/ commands: - - ansible-playbook -i inventory/hosts site.yml --private-key /root/.ssh/id_ed25519 + - ansible-playbook -i inventory/hosts site.yml --private-key /drone/src/.ssh/id_ed25519 -volumes: - - name: ssh-keys - host: - path: /home/ansible/.ssh/ -- 2.49.1 From 640c6472ef386faafe26d506df22ce03266b2a37 Mon Sep 17 00:00:00 2001 From: Noah Knegt Date: Fri, 31 Mar 2023 09:50:30 +0200 Subject: [PATCH 3/4] Fix the yamllint errors Signed-off-by: Noah Knegt --- .drone.yml | 1 - inventory/group_vars/all.yml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4c547bc..b098756 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,4 +28,3 @@ steps: image: cytopia/ansible:alpine commands: - ansible-playbook -i inventory/hosts site.yml --private-key /drone/src/.ssh/id_ed25519 - diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml index 146ddd8..a2d0440 100644 --- a/inventory/group_vars/all.yml +++ b/inventory/group_vars/all.yml @@ -1 +1,2 @@ +--- ansible_user: ansible -- 2.49.1 From e349df3ff5e3ccd0e81a690faca0203bd304a917 Mon Sep 17 00:00:00 2001 From: Noah Knegt Date: Fri, 31 Mar 2023 09:55:17 +0200 Subject: [PATCH 4/4] Update the docker tag for ansible Signed-off-by: Noah Knegt --- .drone.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index b098756..ccee337 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,8 +23,18 @@ steps: environment: SSH_KEY: from_secret: ssh_key + when: + event: + - push + branch: + - master - name: ansible apply - image: cytopia/ansible:alpine + image: cytopia/ansible:infra commands: - ansible-playbook -i inventory/hosts site.yml --private-key /drone/src/.ssh/id_ed25519 + when: + event: + - push + branch: + - master -- 2.49.1