[INFO] Création du rôle
This commit is contained in:
commit
66ac297cc7
75
README.md
Normal file
75
README.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# role_ansible
|
||||||
|
|
||||||
|
Rôle de déploiement d'ansible.
|
||||||
|
|
||||||
|
## Variables
|
||||||
|
|
||||||
|
Afin de ne pas rentrer en conflit avec les variables d'ansible, le variable son préfixer par elbisna soit ansible écrit en partant de la fin.
|
||||||
|
|
||||||
|
### elbisna_prerequisites
|
||||||
|
|
||||||
|
Liste des paquets pré-requis.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> `["python3-pip"]`
|
||||||
|
|
||||||
|
### elbisna_pip_packages
|
||||||
|
|
||||||
|
Liste des paquets pip nécessaire.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> `["ansible", "netaddr"]`
|
||||||
|
|
||||||
|
### elbisna_vault_passwd
|
||||||
|
|
||||||
|
Contient le mot de passe vault.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
|
||||||
|
|
||||||
|
### elbisna_user
|
||||||
|
|
||||||
|
Utilisateur de déploiement d'ansible.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
|
||||||
|
|
||||||
|
### elbisna_group
|
||||||
|
|
||||||
|
Groupe de déploiement d'ansible.
|
||||||
|
|
||||||
|
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
|
||||||
|
|
||||||
|
## Exemple d'utilisation
|
||||||
|
|
||||||
|
### inventory.yml
|
||||||
|
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
all:
|
||||||
|
hosts:
|
||||||
|
host1.ykn.local:
|
||||||
|
```
|
||||||
|
|
||||||
|
### group_vars/all.yml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
elbisna_vault_passwd: !vault |
|
||||||
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
|
31383335306534333462613832646537376232386465643262306134653931383863336133306561
|
||||||
|
3964303562336532393334343530636161343366656539620a326337376232623163323439303735
|
||||||
|
39656634356366306361366537663939653336323432646335656230663133393039343638363536
|
||||||
|
6565336166666261350a343937373733396131623962303237316661666539653432326136306239
|
||||||
|
3538
|
||||||
|
```
|
||||||
|
|
||||||
|
### playbook.yml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
|
||||||
|
- hosts: 'all'
|
||||||
|
roles:
|
||||||
|
- name: ansible
|
||||||
|
```
|
||||||
|
|
14
defaults/main.yml
Normal file
14
defaults/main.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
# defaults file for ansible
|
||||||
|
|
||||||
|
elbisna_prerequisites:
|
||||||
|
- python3-pip
|
||||||
|
|
||||||
|
elbisna_pip_packages:
|
||||||
|
- ansible
|
||||||
|
- netaddr
|
||||||
|
|
||||||
|
elbisna_vault_passwd: ""
|
||||||
|
|
||||||
|
elbisna_user: ""
|
||||||
|
elbisna_group: ""
|
15
meta/main.yml
Normal file
15
meta/main.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
galaxy_info:
|
||||||
|
namespace: ykn
|
||||||
|
author: pulsar89.5
|
||||||
|
description: Rôle de déploiement d'ansible
|
||||||
|
|
||||||
|
license: GPL-3.0-or-later
|
||||||
|
|
||||||
|
min_ansible_version: '2.1'
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
|
||||||
|
dependencies: []
|
22
tasks/configuration.yml
Normal file
22
tasks/configuration.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
# tasks file for ansible
|
||||||
|
|
||||||
|
- name: Déployer le mot de passe vault
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "~{{ elbisna_user }}/.ansible_vault_passwd"
|
||||||
|
content: "{{ elbisna_vault_passwd }}"
|
||||||
|
owner: "{{ elbisna_user }}"
|
||||||
|
group: "{{ elbisna_group }}"
|
||||||
|
mode: u=rw,g=,o=
|
||||||
|
when: elbisna_vault_passwd | length > 0
|
||||||
|
become: true
|
||||||
|
diff: false
|
||||||
|
|
||||||
|
- name: Déployer la configuration
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: ansible.cfg.j2
|
||||||
|
dest: "~{{ elbisna_user }}/.ansible.cfg"
|
||||||
|
owner: "{{ elbisna_user }}"
|
||||||
|
group: "{{ elbisna_group }}"
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
become: true
|
13
tasks/installation.yml
Normal file
13
tasks/installation.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
# tasks file for ansible
|
||||||
|
|
||||||
|
- name: Installer les prérequis
|
||||||
|
ansible.builtin.apt:
|
||||||
|
install_recommends: false
|
||||||
|
name: "{{ elbisna_prerequisites }}"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Installer ansible
|
||||||
|
ansible.builtin.pip:
|
||||||
|
name: "{{ elbisna_pip_packages }}"
|
||||||
|
become: true
|
10
tasks/main.yml
Normal file
10
tasks/main.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# tasks file for ansible
|
||||||
|
|
||||||
|
- name: Importer les tâches d'installation
|
||||||
|
tags: installation
|
||||||
|
ansible.builtin.import_tasks: installation.yml
|
||||||
|
|
||||||
|
- name: Importer les tâches de configuration
|
||||||
|
tags: configuration
|
||||||
|
ansible.builtin.import_tasks: configuration.yml
|
14
templates/ansible.cfg.j2
Normal file
14
templates/ansible.cfg.j2
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
|
[defaults]
|
||||||
|
inventory = inventory.yml
|
||||||
|
host_key_checking = False
|
||||||
|
inject_facts_as_vars = False
|
||||||
|
remote_user = ansible
|
||||||
|
vault_password_file = ${HOME}/.ansible_vault_passwd
|
||||||
|
|
||||||
|
[inventory]
|
||||||
|
enable_plugins = yaml
|
||||||
|
|
||||||
|
[diff]
|
||||||
|
always = yes
|
Loading…
Reference in New Issue
Block a user