feat: Add compatibility with CoreOS

This commit is contained in:
pulsar89.5 2025-03-30 06:22:54 +02:00
parent b787b15353
commit 94dcd1374e
8 changed files with 56 additions and 72 deletions

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
# Lancer une pipeline
request=$(curl --silent --request POST --header "Authorization: Bearer ${DRONE_TOKEN}" ${DRONE_BASE_URL}/api/repos/${DRONE_REPOSITORY_PATH}/builds${DRONE_URL_PARAM} | jq .number)
# Attendre que la pipeline ne soit plus en exécution
while true; do
# Récupérer l'état de la pipeline
status=$(curl --silent --request GET --header "Authorization: Bearer ${DRONE_TOKEN}" ${DRONE_BASE_URL}/api/repos/${DRONE_REPOSITORY_PATH}/builds/$request | jq .status)
case "${status}" in
"\"pending\"" | "\"running\"")
sleep 5s
;;
"\"success\"")
echo "${DRONE_REPOSITORY_PATH}: ${status}"
exit 0
;;
*)
echo "${DRONE_REPOSITORY_PATH}: ${status}"
exit 1
;;
esac
done

View File

@ -1,7 +1,7 @@
---
# handlers file for drone_runner_exec
- name: Redémarrer drone-runner-exec.service
- name: Restart drone-runner-exec.service
ansible.builtin.systemd:
enabled: true
daemon_reload: true

View File

@ -11,6 +11,9 @@ galaxy_info:
- name: Debian
versions:
- all
- name: CoreOS
varsions:
- 41
dependencies:
- role: users

View File

@ -1,7 +1,7 @@
---
# tasks file for drone_runner_exec
- name: Créer le dossier de configuration
- name: Create configuration path
ansible.builtin.file:
state: directory
path: "{{ drone_runner_exec_config_base_path }}"
@ -10,7 +10,7 @@
mode: u=rwX,g=rX,o=rX
become: true
- name: Créer le dossier de journalisation
- name: Create log path
ansible.builtin.file:
state: directory
path: /var/log/drone-runner-exec
@ -19,7 +19,7 @@
mode: u=rwX,g=rX,o=rX
become: true
- name: Configurer le runner
- name: Deploy configuration
ansible.builtin.template:
src: config.j2
dest: "{{ drone_runner_exec_config_base_path }}/config"
@ -29,26 +29,26 @@
become: true
notify: Redémarrer drone-runner-exec.service
- name: Récupérer les faits sur les services
- name: Get service facts
ansible.builtin.service_facts:
- name: Installer drone-runner.service
- name: Install runner service
ansible.builtin.command:
cmd: >-
/opt/drone-runner-exec/drone-runner-exec service install
/usr/local/bin/drone-runner-exec service install
--config="{{ drone_runner_exec_config_base_path }}/config"
when: "'drone-runner-exec.service' not in ansible_facts.services"
become: true
notify: Redémarrer drone-runner-exec.service
notify: Restart drone-runner-exec.service
- name: Créer le dossier de surcharge du service
- name: Create systemd override directory
ansible.builtin.file:
state: directory
path: /etc/systemd/system/drone-runner-exec.service.d
mode: u=rwX,g=rX,o=rX
become: true
- name: Définir l'utilisateur du service
- name: Deploy systemd override configuration
ansible.builtin.template:
src: override.conf.j2
dest: /etc/systemd/system/drone-runner-exec.service.d/override.conf
@ -57,13 +57,3 @@
mode: u=rwX,g=rX,o=rX
become: true
notify: Redémarrer drone-runner-exec.service
- name: Déployer le script permettant d'exécuter un pipeline depuis une autre
ansible.builtin.copy:
src: drone-downstream.bash
dest: /opt/drone-runner-exec/drone-downstream.bash
owner: root
group: root
mode: u=rwx,g=rx,o=rx
become: true
diff: false

View File

@ -0,0 +1,7 @@
---
# tasks file for ansible
- name: Install prerequisites
ansible.builtin.apt:
name: "{{ drone_runner_exec_prerequisites }}"
become: true

View File

@ -0,0 +1,19 @@
---
# tasks file for borgmatic
- name: Install prerequisites
ansible.builtin.command:
argv: "{{ rpm_ostree + drone_runner_exec_prerequisites }}"
creates: /sysroot/ostree/repo/refs/heads/rpmostree/pkg/borgmatic
become: true
vars:
rpm_ostree:
- /usr/bin/rpm-ostree
- install
- --allow-inactive
- --assumeyes
- --idempotent
notify: Apply installation
- name: Flush handlers
meta: flush_handlers

View File

@ -1,29 +1,14 @@
---
# tasks file for drone_runner_exec
- name: Installer les prérequis
ansible.builtin.package:
name: "{{ item }}"
become: true
loop: "{{ drone_runner_exec_prerequisites }}"
- name: Créer le dossier dédié
ansible.builtin.file:
path: /opt/drone-runner-exec
state: directory
owner: root
group: root
mode: u=rwX,g=rX,o=rX
become: true
- name: Récupérer le contenu du fichier de version
- name: Get version file
ansible.builtin.uri:
url: "{{ drone_runner_exec_url }}"
return_content: true
follow_redirects: all
register: releases
- name: Extraire l'URL du paquet
- name: Extract URL
ansible.builtin.set_fact:
browser_download_url: >
{{
@ -33,14 +18,14 @@
map(attribute='browser_download_url')
}}
- name: Extraire le runner
- name: Install runner
ansible.builtin.unarchive:
src: "{{ browser_download_url | first }}"
dest: /opt/drone-runner-exec
dest: /usr/local/bin/
remote_src: true
list_files: true
owner: root
group: root
owner: "{{ drone_runner_exec_user }}"
group: "{{ drone_runner_exec_group }}"
mode: u=rwX,g=rX,o=rX
become: true
notify: Redémarrer drone-runner-exec.service
notify: Restart drone-runner-exec.service

View File

@ -1,10 +1,14 @@
---
# tasks file for drone_runner_exec
- name: Importer les tâches d'installation
tags: installation
ansible.builtin.import_tasks: installation.yml
- name: Include installation tasks
ansible.builtin.include_tasks:
file: installation-{{ ansible_facts['pkg_mgr'] }}.yml
- name: Importer les tâches de configuration
tags: configuration
ansible.builtin.import_tasks: configuration.yml
- name: Import service installation tasks
ansible.builtin.import_tasks:
file: installation-service.yml
- name: Import configuration tasks
ansible.builtin.import_tasks:
file: configuration.yml