feat: aggiunto playbook per templates

This commit is contained in:
alessandro.rabiti 2024-11-17 14:35:01 +01:00
parent e8c0509106
commit 202e37c988
4 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,13 @@
---
- name: Edito il file /etc/motd
hosts: all
vars_files: defaults/vars.yaml
tasks:
- name: Edito il file /etc/motd
ansible.builtin.template:
src: motd.j2
dest: /etc/motd
owner: root
group: root
mode: '0644'

View file

@ -25,3 +25,7 @@ cat /tmp/resolv.conf # ← per vedere se il file e' stato editato correttamente
ansible-playbook 3_playbook.yaml -e env=dr
cat /tmp/resolv.conf # ← per vedere se il file e' stato editato correttamente
```
4) Playbook di esempio che utilizza un file di variabili ed un template per editare il file motd degli hosts target:
- per lanciare il playbook usare il seguente comando:
```
ansible-playbook -iinventory -uuser -k 4_playbook.yaml

View file

@ -0,0 +1,13 @@
---
tomcats:
progetto1:
version: '9.0.81'
http: '8081'
ajp: '8901'
shutdown: '8001'
progetto2:
version: '8.5.77'
http: '8082'
ajp: '8902'
shutdown: '8002'

View file

@ -0,0 +1,10 @@
#############################################################################
Questo è l'host {{ inventory_hostname }}
* TOMCAT SHUT HTTP AJP
{% for key, tomcat in tomcats.items() %}
* apache-tomcat-{{ version }}-{{ key }} {{ tomcat.shutdown }} {{ tomcat.http }} {{ tomcat.ajp }}
{% endfor %}
#############################################################################