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