From 856ea2d1a833345946e143edbd93980f29cec73e Mon Sep 17 00:00:00 2001 From: poulpe <poulpe@localhost.localdomain> Date: Sun, 2 Apr 2023 15:52:36 +0200 Subject: [PATCH] [Update] Fix standalone run --- Config_H1_Ping_H2.yml | 46 +++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/Config_H1_Ping_H2.yml b/Config_H1_Ping_H2.yml index 95eb76c..fe8e822 100644 --- a/Config_H1_Ping_H2.yml +++ b/Config_H1_Ping_H2.yml @@ -3,26 +3,27 @@ hosts: all become: true tasks: + - name: Load the variables + include_vars: variables.yml - name: Rename hosts command: hostnamectl set-hostname {{ inventory_hostname }} - notify: rename_finish - - handlers: - - name: rename_finish - debug: - msg: "I can handle dates" - + - name: Setup network for Hosts hosts: hotes become: yes tasks: - name: "Create file interface in interfaces.d" ansible.builtin.template: - src: ./interfaces_H.j2 + src: ./templates/host_config_template.j2 dest: /etc/network/interfaces.d/interfaces_playbook.conf mode: 0640 - - name: Restart interfaces hosts - shell: "ifdown --force eth0" + notify: Restart network + handlers: + - name: Restart network + ansible.builtin.service: + name: networking + state: restarted + enabled: yes - name: Setup network for Routers hosts: routeurs @@ -30,31 +31,20 @@ tasks: - name: "Create file interface in interfaces.d" ansible.builtin.template: - src: ./interfaces_R.j2 + src: ./templates/router_config_template.j2 dest: /etc/network/interfaces.d/interfaces_playbook.conf mode: 0640 + notify: Restart network - name: "Set ip_forwarding to 1" ansible.posix.sysctl: name: net.ipv4.ip_forward value: '1' sysctl_set: true state: present - - name: Restart interfaces hosts - shell: "ifdown --force eth0 eth1" - - -- name: Configuration et démarrage des interfaces réseau - hosts: all - become: true - tasks: - - name: Restart interfaces hosts - shell: "ifup -a --ignore-errors" - notify: start network - handlers: - - name: start network - service: - name: networking - state: restarted - enabled: yes + - name: Restart network + ansible.builtin.service: + name: networking + state: restarted + enabled: yes ... \ No newline at end of file -- GitLab