feat: aggiunta la directory 6_check_ansible-lint
This commit is contained in:
parent
5c84fbd77e
commit
001ee75abc
9 changed files with 127 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
---
|
---
|
||||||
all:
|
all:
|
||||||
hosts:
|
hosts:
|
||||||
host1test.mydomain.xyz:
|
host1test.mydomain.xyz:
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@ gruppo_test:
|
||||||
hosts:
|
hosts:
|
||||||
host1test.mydomain.xyz:
|
host1test.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.2
|
ansible_host: 127.0.0.2
|
||||||
host2test.mydomain.xyz:
|
host2test.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.3
|
ansible_host: 127.0.0.3
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ gruppo_test:
|
||||||
hosts:
|
hosts:
|
||||||
host1test.mydomain.xyz:
|
host1test.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.2
|
ansible_host: 127.0.0.2
|
||||||
host2test.mydomain.xyz:
|
host2test.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.3
|
ansible_host: 127.0.0.3
|
||||||
vars:
|
vars:
|
||||||
ansible_user: nobody
|
ansible_user: nobody
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ gruppo_test:
|
||||||
hosts:
|
hosts:
|
||||||
host1test.mydomain.xyz:
|
host1test.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.2
|
ansible_host: 127.0.0.2
|
||||||
host2test.mydomain.xyz:
|
host2test.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.3
|
ansible_host: 127.0.0.3
|
||||||
vars:
|
vars:
|
||||||
ansible_user: nobody
|
ansible_user: nobody
|
||||||
|
|
@ -12,7 +12,7 @@ gruppo_prod:
|
||||||
hosts:
|
hosts:
|
||||||
host1prod.mydomain.xyz:
|
host1prod.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.4
|
ansible_host: 127.0.0.4
|
||||||
host2prod.mydomain.xyz:
|
host2prod.mydomain.xyz:
|
||||||
ansible_host: 127.0.0.5
|
ansible_host: 127.0.0.5
|
||||||
vars:
|
vars:
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
|
|
|
||||||
10
6_check_ansible-lint/11_playbook.yaml
Normal file
10
6_check_ansible-lint/11_playbook.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- name: Stampo a video le facts # nome di questo play, ora gli spazi sono assenti
|
||||||
|
hosts: all # specifica su quali hosts o gruppi di hosts deve essere eseguito questo play
|
||||||
|
become: false # utilizza i privilegi di root (default false)
|
||||||
|
gather_facts: true # raccoglie i dati sull'host (default true)
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Stampo a video tutte le facts degli hosts
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: ansible_facts
|
||||||
11
6_check_ansible-lint/1_playbook.yaml
Normal file
11
6_check_ansible-lint/1_playbook.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Stampo a video le facts # nome di questo play, in questa riga c'è qualche spazio di troppo
|
||||||
|
hosts: all # specifica su quali hosts o gruppi di hosts deve essere eseguito questo play
|
||||||
|
become: false # utilizza i privilegi di root (default false)
|
||||||
|
gather_facts: true # raccoglie i dati sull'host (default true)
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Stampo a video tutte le facts degli hosts
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: ansible_facts
|
||||||
|
|
||||||
23
6_check_ansible-lint/21_inventory.yaml
Normal file
23
6_check_ansible-lint/21_inventory.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
gruppo_test:
|
||||||
|
hosts:
|
||||||
|
host1test.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.2
|
||||||
|
host2test.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.3
|
||||||
|
vars:
|
||||||
|
ansible_user: nobody
|
||||||
|
|
||||||
|
gruppo_prod:
|
||||||
|
hosts:
|
||||||
|
host1prod.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.4
|
||||||
|
host2prod.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.5
|
||||||
|
vars:
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
gruppo_all:
|
||||||
|
children:
|
||||||
|
gruppo_test:
|
||||||
|
gruppo_prod:
|
||||||
24
6_check_ansible-lint/2_inventory.yaml
Normal file
24
6_check_ansible-lint/2_inventory.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
gruppo_test:
|
||||||
|
hosts:
|
||||||
|
host1test.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.2
|
||||||
|
host2test.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.3
|
||||||
|
vars:
|
||||||
|
ansible_user: nobody
|
||||||
|
|
||||||
|
gruppo_prod:
|
||||||
|
|
||||||
|
hosts:
|
||||||
|
host1prod.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.4
|
||||||
|
host2prod.mydomain.xyz:
|
||||||
|
ansible_host: 127.0.0.5
|
||||||
|
vars:
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
gruppo_all:
|
||||||
|
children:
|
||||||
|
gruppo_test:
|
||||||
|
gruppo_prod:
|
||||||
54
6_check_ansible-lint/README.md
Normal file
54
6_check_ansible-lint/README.md
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Controllo della sintassi di un playbook con ansible lint
|
||||||
|
|
||||||
|
Prima di procedere, verificare che il pacchetto ansible-lint sia installato → # ansible-lint --version
|
||||||
|
nel caso in cui non sia installato, installarlo con i seguenti comandi:
|
||||||
|
|
||||||
|
- Installazione su OracleLinux8
|
||||||
|
```
|
||||||
|
dnf install ansible-lint -y
|
||||||
|
```
|
||||||
|
- Installazione su OracleLinux9
|
||||||
|
```
|
||||||
|
dnf install ansible-lint -y
|
||||||
|
```
|
||||||
|
- Installazione du Debian12
|
||||||
|
```
|
||||||
|
apt-get update
|
||||||
|
apt-get install ansible-lint -y
|
||||||
|
```
|
||||||
|
|
||||||
|
1) Esempio di check su un playbook che presena errori sintattici quali spazi vuoti o identazione non corretta
|
||||||
|
- per lanciare il check sul playbook:
|
||||||
|
```
|
||||||
|
ansible-lint 1_playbook.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
1.1) Esempio di check su un playbook che non presena errori sintattici
|
||||||
|
- per lanciare il playbook:
|
||||||
|
```
|
||||||
|
ansible-lint 11_playbook.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
1.2) Verifica delle differenze tra i due files appena testati con ansible-lint
|
||||||
|
- confronto dei files con vimdiff:
|
||||||
|
```
|
||||||
|
vimdiff 1_playbook.yaml 11_playbook.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
2) Esempio di check su un inventory (in formato yaml) che presena errori sintattici quali spazi vuoti o identazione non corretta
|
||||||
|
- per lanciare il check sull'inventory:
|
||||||
|
```
|
||||||
|
ansible-lint 2_inventory.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
2.1) Esempio di check su un inventory (in formato yaml) che non presena errori sintattici
|
||||||
|
- per lanciare il check sull'inventory:
|
||||||
|
```
|
||||||
|
ansible-lint 21_inventory.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
2.2) Verifica delle differenze tra i due files appena testati con ansible-lint
|
||||||
|
- confronto dei files con vimdiff:
|
||||||
|
```
|
||||||
|
vimdiff 2_inventory.yaml 21_inventory.yaml
|
||||||
|
```
|
||||||
Loading…
Add table
Reference in a new issue