deploy_keepalived/molecule/with_custom_conf/prepare.yml
Bertrand Lanson 9bd6da5a67
All checks were successful
test / Linting (push) Successful in 12s
test / Molecule tests (default, debian11) (push) Successful in 3m8s
test / Molecule tests (default, debian12) (push) Successful in 3m23s
test / Molecule tests (default, ubuntu2204) (push) Successful in 3m36s
test / Molecule tests (with_custom_conf, debian12) (push) Successful in 3m41s
test / Molecule tests (default, ubuntu2004) (push) Successful in 3m45s
test / Molecule tests (with_custom_conf, debian11) (push) Successful in 3m46s
test / Molecule tests (with_custom_conf, ubuntu2004) (push) Successful in 4m2s
test / Molecule tests (with_custom_conf, ubuntu2204) (push) Successful in 2m47s
feat(config): add custom template option
2024-03-11 19:29:02 +01:00

56 lines
1.8 KiB
YAML

---
- name: Prepare
hosts: all
become: true
tasks:
- name: "Generate custom keepalived.conf template" # noqa: run-once[task]
delegate_to: localhost
run_once: true
block:
- name: "Generate custom keepalived.conf template"
ansible.builtin.copy:
content: |
{% raw -%}
# {{ ansible_managed }}
# THIS IS A CUSTOM CONF
global_defs {
script_user keepalived_script
enable_script_security
}
vrrp_instance {{ deploy_keepalived_vrrp_instance_name }} {
interface {{ deploy_keepalived_interface }}
state {{ deploy_keepalived_state }}
virtual_router_id {{ deploy_keepalived_router_id }}
priority {{ deploy_keepalived_priority }}
advert_int {{ deploy_keepalived_advert_interval }}
nopreempt
{% if deploy_keepalived_unicast_peers %}
unicast_src_ip {{ deploy_keepalived_unicast_source }}
unicast_peer {
{% for peer in deploy_keepalived_unicast_peers %}
{{ peer }}
{% endfor %}
}
{% endif %}
authentication {
auth_type PASS
auth_pass {{ deploy_keepalived_auth_passwd }}
}
virtual_ipaddress {
{% for vip in deploy_keepalived_virtual_ips %}
{{ vip }}
{% endfor %}
}
notify {{ deploy_keepalived_scripts_dir }}/{{ deploy_keepalived_notify_script }}
}
{%- endraw %}
dest: /tmp/keepalived.conf.j2
mode: '0644'