diff --git a/roles/nat_server/tasks/main.yml b/roles/nat_server/tasks/main.yml index cefd82f1bafb89fb0551b4b2132fc869bfbc8923..9a968c545c565412b7891ad1590988473f1cc129 100644 --- a/roles/nat_server/tasks/main.yml +++ b/roles/nat_server/tasks/main.yml @@ -68,6 +68,11 @@ become: true become_user: root +- name: Template keepalived service file + template: dest=/etc/systemd/system/keepalived.service src=keepalived.service.j2 + become: true + become_user: root + - name: Enable and start keepalived service: name: keepalived @@ -75,3 +80,11 @@ enabled: yes become: true become_user: root + +- name: Restart iptables service + service: + name: iptables + state: restarted + become: true + become_user: root + diff --git a/roles/nat_server/templates/keepalived.service.j2 b/roles/nat_server/templates/keepalived.service.j2 new file mode 100644 index 0000000000000000000000000000000000000000..353658150a699d8a871b4d5500990b0c2b9bba66 --- /dev/null +++ b/roles/nat_server/templates/keepalived.service.j2 @@ -0,0 +1,14 @@ +# systemd servive unit file for Keepalived +[Unit] +Description=Keepalived service for High Availability with VRRP +After=network.target network-online.target +ConditionFileNotEmpty=/etc/keepalived/keepalived.conf + +[Service] +Type=simple +ExecStart=/usr/sbin/keepalived --dont-fork +ExecReload=/bin/kill -s HUP $MAINPID #Define the procedure of killing the processes belonging to the Keepalived service unit. +KillMode=process + +[Install] +WantedBy=multi-user.target