[INFO] Créer le dépôt
This commit is contained in:
parent
aa882a7951
commit
120f7aa01f
68
README.md
68
README.md
@ -1,3 +1,67 @@
|
|||||||
# role_modele
|
# role_drone_cli
|
||||||
|
|
||||||
Modèle
|
Rôle de déploiement de l'exécutable CLI de drone.io.
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
### drone_cli_url
|
||||||
|
|
||||||
|
URL pointant vers l'API de github.com fournissant le lien de téléchargement de l'archive.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> `https://api.github.com/repos/harness/drone-cli/releases/latest`
|
||||||
|
|
||||||
|
### drone_cli_architecture
|
||||||
|
|
||||||
|
Nécessaire pour télécharger la bonne archive depuis github.com.<br />
|
||||||
|
Les architectures disponibles sont visibles dans [la liste de release du dépôt](https://github.com/harness/drone-cli/releases).
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> `arm64`
|
||||||
|
|
||||||
|
### drone_cli_server_url
|
||||||
|
|
||||||
|
URL vers le serveur drone.io.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
|
||||||
|
|
||||||
|
### drone_cli_server_token
|
||||||
|
|
||||||
|
Clef pour communiquer avec le serveur drone.io.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
|
||||||
|
|
||||||
|
### drone_cli_commands_args
|
||||||
|
|
||||||
|
Liste des arguments passés à la commande `drone`.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
|
||||||
|
|
||||||
|
## Exemple d'utilisation
|
||||||
|
|
||||||
|
### inventory.yml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
all:
|
||||||
|
hosts:
|
||||||
|
host1.ykn.local:
|
||||||
|
```
|
||||||
|
|
||||||
|
### host_vars/host1.ykn.local.yml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
drone_cli_architecture: "amd64"
|
||||||
|
dron
|
||||||
|
```
|
||||||
|
|
||||||
|
### playbook.yml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
- hosts: 'all'
|
||||||
|
roles:
|
||||||
|
- name: drone_cli
|
||||||
|
```
|
||||||
|
10
defaults/main.yml
Normal file
10
defaults/main.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# defaults file for drone_cli
|
||||||
|
|
||||||
|
drone_cli_architecture: "arm64"
|
||||||
|
drone_cli_url: https://api.github.com/repos/harness/drone-cli/releases/latest
|
||||||
|
|
||||||
|
drone_cli_server_url: ""
|
||||||
|
drone_cli_server_token: ""
|
||||||
|
|
||||||
|
drone_cli_commands_args: []
|
8
handlers/main.yml
Normal file
8
handlers/main.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# handlers file for drone_cli
|
||||||
|
|
||||||
|
- name: Installer la commande
|
||||||
|
ansible.builtin.command:
|
||||||
|
chdir: /opt
|
||||||
|
cmd: install -t /usr/local/bin drone
|
||||||
|
become: true
|
28
tasks/configuration.yml
Normal file
28
tasks/configuration.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
# tasks file for drone_cli
|
||||||
|
|
||||||
|
- name: Récupérer les informations
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: drone {{ item.type }} info {{ item.target }} {{ item.name }}
|
||||||
|
environment:
|
||||||
|
DRONE_SERVER: "{{ drone_cli_server_url }}"
|
||||||
|
DRONE_TOKEN: "{{ drone_cli_server_token }}"
|
||||||
|
register: info
|
||||||
|
changed_when: info.rc != 0
|
||||||
|
diff: false
|
||||||
|
|
||||||
|
- name: Déterminer qu'il faut mettre à jour
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
cmd_action: update
|
||||||
|
when:
|
||||||
|
- info.rc == 0
|
||||||
|
- item.type in cmd_updatable
|
||||||
|
|
||||||
|
- name: Exécuter les commandes
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: drone {{ item.type }} {{ cmd_action }} {{ item.target }} {{ item.name }} {{ item.data }}
|
||||||
|
environment:
|
||||||
|
DRONE_SERVER: "{{ drone_cli_server_url }}"
|
||||||
|
DRONE_TOKEN: "{{ drone_cli_server_token }}"
|
||||||
|
changed_when: info.rc != 0
|
||||||
|
diff: false
|
32
tasks/installation.yml
Normal file
32
tasks/installation.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
# tasks file for drone_cli
|
||||||
|
|
||||||
|
- name: Récupérer le contenu du fichier de version
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ drone_cli_url }}"
|
||||||
|
return_content: true
|
||||||
|
follow_redirects: all
|
||||||
|
register: releases
|
||||||
|
|
||||||
|
- name: Extraire l'URL du paquet
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
browser_download_url: >
|
||||||
|
{{
|
||||||
|
releases.json.assets |
|
||||||
|
selectattr('browser_download_url', 'search', 'linux') |
|
||||||
|
selectattr('browser_download_url', 'search', drone_cli_architecture) |
|
||||||
|
map(attribute='browser_download_url')
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Extraire le runner
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: "{{ browser_download_url | first }}"
|
||||||
|
dest: /opt/
|
||||||
|
remote_src: true
|
||||||
|
list_files: true
|
||||||
|
mode: u=rwX,g=rX,o=rX
|
||||||
|
become: true
|
||||||
|
notify: Installer la commande
|
||||||
|
|
||||||
|
- name: Exécuter les handlers
|
||||||
|
ansible.builtin.meta: flush_handlers
|
16
tasks/main.yml
Normal file
16
tasks/main.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
# tasks file for drone_cli
|
||||||
|
|
||||||
|
- name: Importer les tâches d'installation
|
||||||
|
tags: installation
|
||||||
|
ansible.builtin.import_tasks: installation.yml
|
||||||
|
|
||||||
|
- name: Inclure les tâches de configuration
|
||||||
|
tags: configuration
|
||||||
|
ansible.builtin.include_tasks: configuration.yml
|
||||||
|
when:
|
||||||
|
- drone_cli_server_url | length > 0
|
||||||
|
- drone_cli_server_token | length > 0
|
||||||
|
- drone_cli_commands | length > 0
|
||||||
|
loop: "{{ drone_cli_commands }}"
|
||||||
|
run_once: true
|
8
vars/main.yml
Normal file
8
vars/main.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# vars file for drone_cli
|
||||||
|
|
||||||
|
cmd_action: add
|
||||||
|
cmd_updatable:
|
||||||
|
- secret
|
||||||
|
- orgsecret
|
||||||
|
- template
|
Loading…
Reference in New Issue
Block a user