From 17b9117efdc949e0eb8f38ba76599bb6ad18eac7 Mon Sep 17 00:00:00 2001 From: Guy Godfroy Date: Mon, 20 Jul 2020 16:05:30 +0200 Subject: [PATCH] coding --- handlers/main.yml | 3 ++- tasks/main.yml | 11 +++++++++++ templates/hostname.carp.j2 | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 templates/hostname.carp.j2 diff --git a/handlers/main.yml b/handlers/main.yml index b637c75..34f27b6 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,3 @@ --- -# handlers file for openbsd-carp \ No newline at end of file +- name: start carp{{ carp.num }} + command: "sh /etc/netstart carp{{ carp.num }}" diff --git a/tasks/main.yml b/tasks/main.yml index 8cc8cd4..6d411b8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,3 +9,14 @@ name: net.inet.carp.preempt value: '1' when: openbsd_carp_preempt + +- name: Configure carp{{ carp.num }} + template: + src: hostname.carp.j2 + dest: /etc/hostname.carp{{ carp.num }} + notify: start carp{{ carp.num }} + loop: "{{ openbsd_carp | flatten(level=1) }}" + loop_control: + loop_var: carp + +- meta: flush_handlers diff --git a/templates/hostname.carp.j2 b/templates/hostname.carp.j2 new file mode 100644 index 0000000..046715a --- /dev/null +++ b/templates/hostname.carp.j2 @@ -0,0 +1,7 @@ +inet {{ carp.ip | ipaddr('address') }} {{ carp.ip | ipaddr('netmask') }} {{ carp.ip | ipaddr('broadcast') }} +vhid {{ carp.vhid }} +carpdev {{ carp.interface }} +pass "{{ carp.password }}" +{% if carp.description is defined %} +description "{{ carp.description }}" +{% endif %}