====== Netplan / Cloud-init ======
===== Cloud Init ? =====
Informations sur Cloud-init:
* [[https://blog.octo.com/cloudinit-kesako/]]
===== NetPlan =====
todo
===== Installation =====
Normalement cloud-init est installé avec la version Ubuntu 18.04.
Si ce n'est pas le cas, on peut l'installer avec:
Les paquet **cloud-init** et **netplan.io** doivent etre installés
sudo apt install cloud-init netplan.io
==== Passer de Interfaces a Cloud-init ====
Source : [[https://askubuntu.com/questions/1034711/how-to-enable-netplan-on-ubuntu-server-upgraded-from-16-04-to-18-04]]
- On créé un fichier **/etc/netplan/config.yaml** avec [[#configuration|la config ci dessous]]
- On applique la configuration avec ''sudo netplan apply''
- On supprime le paquet ifupdown ''sudo apt purge ifupdown''
- On reboot
===== Configuration =====
==== Fichier de configuration ====
* Le nom de fichier peut etre : **config.yaml**
* Le nom de l'interface doit correspondre avec l'interface réélle, **ATTENTION aux copié/collé**.
Pour voir les interface de votre machine utilisez [[linux:commandes:networkctl]]
thierry@binova-srv:~$ networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
3 ens18 ether routable configured
2 links listed.
[[linux:reseau|autres commandes utiles pour la gestion du réseau]]
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens18:
addresses:
- 192.168.1.104/24
dhcp4: false
gateway4: 192.168.1.1
nameservers:
search: [binova.com]
addresses: [127.0.0.1, 192.168.1.1, 8.8.8.8]
version: 2
==== Compilation du fichier ====
Toute modification du fichier doit étre suivi de la compilation de celui-ci avec la commande ''sudo netplan generate''
On "compile" le fichier avec un thierry@bino:~$ sudo netplan generate
==== Vérification ====
Un fichier est généré:
[Match]
Name=ens18
[Network]
Address=192.168.1.104/24
Gateway=192.168.1.1
DNS=127.0.0.1
DNS=192.168.1.1
DNS=8.8.8.8
Domains=binova.com
==== Application des modifs ====
et on redemarre le réseau avec:
thierry@bino:~$ sudo systemctl restart systemd-networkd
Et on peut constater que le fichier resolv.conf a été mis a jour...
# This file is managed by man:systemd-resolved(8). Do not edit.
...
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
search binova.com
===== Sources =====
* [[https://netplan.io/reference]](Eng)
* [[https://netplan.io/examples]](Eng)
* [[https://www.dsfc.net/logiciel-libre/linux/ubuntu-linux-logiciel-libre/configuration-reseau-dans-ubuntu-bionic-aurions-nous-touche-le-fond/]](Fra)