feat: aggiunto playbook per templates
This commit is contained in:
parent
e8c0509106
commit
202e37c988
4 changed files with 40 additions and 0 deletions
13
9_template/4_playbook.yaml
Normal file
13
9_template/4_playbook.yaml
Normal 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'
|
||||
|
|
@ -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
|
||||
|
|
|
|||
13
9_template/defaults/vars.yaml
Normal file
13
9_template/defaults/vars.yaml
Normal 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'
|
||||
10
9_template/templates/motd.j2
Normal file
10
9_template/templates/motd.j2
Normal 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 %}
|
||||
|
||||
#############################################################################
|
||||
Loading…
Add table
Reference in a new issue