Solution
Web
---
- hosts: all
tasks:
- name: Installation Apache
dnf:
name: httpd
state: latest
- name: Démarrage service
service:
name: httpd
state: started
enabled: yes
- name: Copie index.html
copy:
src: /root/index.html
dest: /var/www/html
...
ntp (incluant le handler)
---
- hosts: all
tasks:
- name: Installation Chrony
dnf:
name: chrony
state: latest
- name: Configuration Chrony
lineinfile:
path: /etc/chrony.conf
line: "{{ item }}"
state: present
with_items:
- 'Server 0.ca.pool.ntp.org'
- 'Server 1.ca.pool.ntp.org'
- 'Server 2.ca.pool.ntp.org'
- 'Server 3.ca.pool.ntp.org'
notify:
- Redémarre NTP
handlers:
- name: Redémarre NTP
service:
name: chronyd
state: restarted
...
dns
---
- hosts: all
tasks:
- name: Configuration des DNS
# le module utilisé
lineinfile:
# spécifie le chemin du fichier à modifier
path: /etc/resolv.conf
# On spécifie que les lignes à ajouter le seront au sein d'une indentation
line: "nameserver 8.8.8.8"
# Les lignes devront être présentes dans le fichier (ajoutées le cas échéant)
state: present
with_items:
- 'nameserver 8.8.8.8'
- 'nameserver 8.8.4.4'
...
hosts
---
- hosts: all
tasks:
- name: Copie hosts
template:
src: /root/hosts
dest: /etc/hosts
...
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
{{ ansible_default_ipv4.address }} {{ ansible_fqdn }}