From e975d1e2ae68e71ea6eb8a62d31a24e835b7e3cd Mon Sep 17 00:00:00 2001 From: "pulsar89.5" Date: Tue, 18 Apr 2023 17:35:39 +0200 Subject: [PATCH] =?UTF-8?q?[INFO]=20Cr=C3=A9ation=20du=20r=C3=B4le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++-- defaults/main.yml | 5 +++++ meta/main.yml | 3 +-- tasks/main.yml | 20 ++++++++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 defaults/main.yml create mode 100644 tasks/main.yml diff --git a/README.md b/README.md index 3edfbf7..b1923c6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,43 @@ -# role_modele +# role_ipforwarding -Modèle \ No newline at end of file +Rôle de déploiement de l'ipforwarding. + +## Variables + +### ipforwarding_ipv4 + +Permet d'activer ou désactiver le forwarding pour IPv4. + +*Valeur par défaut: aucune* + +Valeur possibles: + - `1` : activer le forwarding + - `0` : désactiver le forwarding + + +### ipforwarding_ipv6 + +Permet d'activer ou désactiver le forwarding pour IPv6. +Les informations sont les mêmes que pour `ipforwarding_ipv4` + +## Exemples + +### group_vars/gw.yml + +```yaml +--- + +ipforwarding_ipv4: 1 +ipforwarding_ipv6: 1 +``` + +### playbook.yml + +```yaml +--- + +- name: Déployer le rôle ipforwarding + hosts: gw + roles: + - name: ipforwarding +``` diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..cc749d6 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +--- +# defaults file for ipforwarding + +ipforwarding_ipv4: 0 +ipforwarding_ipv6: 0 diff --git a/meta/main.yml b/meta/main.yml index c58bebf..45a4b02 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,8 +1,7 @@ galaxy_info: namespace: ykn author: pulsar89.5 - description: Rôle modèle - + description: Rôle de déploiement de l'ipforwarding license: GPL-3.0-or-later min_ansible_version: '2.1' diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..7a0b129 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,20 @@ +--- +# tasks file for ipforwarding + +- name: Changer pour IPv4 + ansible.posix.sysctl: + name: net.ipv4.conf.all.forwarding + value: "{{ ipforwarding_ipv4 | string }}" + sysctl_file: /etc/sysctl.d/100-ipv4_forwarding.conf + sysctl_set: true + become: true + when: ipforwarding_ipv4 | string | length > 0 + +- name: Changer pour IPv6 + ansible.posix.sysctl: + name: net.ipv6.conf.all.forwarding + value: "{{ ipforwarding_ipv6 | string }}" + sysctl_file: /etc/sysctl.d/100-ipv6_forwarding.conf + sysctl_set: true + become: true + when: ipforwarding_ipv6 | string | length > 0 -- 2.39.5