diff --git a/Config_H1_Ping_H2.yml b/Config_H1_Ping_H2.yml index 95eb76c820ef1b4c81f2da2a34f5c4e363afe0d8..fe8e822760f3cc3c25cd43267352b29b73bd3409 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