ADD import roles

This commit is contained in:
2024-09-15 09:42:20 +02:00
parent 4798dde38c
commit e6027e9078
36 changed files with 1129 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
keepalived_enabled: false
keepalived_interfaces: []
+9
View File
@@ -0,0 +1,9 @@
---
- name: Restart keepalived
systemd_service:
name: keepalived.service
state: restarted
enabled: true
when: not ansible_check_mode
- name: Reload sysctl
ansible.builtin.command: sysctl --system
+52
View File
@@ -0,0 +1,52 @@
---
- name: Set OS dependent variables
include_vars: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution | lower }}_{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
- "{{ ansible_system | lower }}.yml"
paths:
- "{{ role_path }}/vars"
ignore_errors: True
tags:
- always
- name: OS is supported
assert:
that: __os_supported
quiet: True
vars:
__os_supported: "{{ lookup('vars', '{}_os_supported'.format(role_name)) | bool }}"
tags:
- always
- name: Install required packages
package:
name: "{{ item }}"
state: present
with_items: "{{ lookup('vars', '{}_packages'.format(role_name)) | list }}"
tags:
- install
- name: Install keepalived configuration
template:
src: keepalived.conf.j2
dest: "/etc/keepalived/keepalived.conf"
owner: root
group: root
mode: 0644
tags:
- configure
no_log: false
notify: Restart keepalived
- name: Enable keepalived service
ansible.builtin.systemd_service:
name: keepalived.service
state: "{{ 'started' if keepalived_enabled else 'stopped' }}"
enabled: "{{ keepalived_enabled }}"
when: not ansible_check_mode
@@ -0,0 +1,27 @@
# {{ ansible_managed }}
vrrp_sync_group G1 {
group {
{%for iface in keepalived_interfaces %}
{{ iface.name }}
{% endfor %}
}
}
{%for iface in keepalived_interfaces %}
vrrp_instance {{ iface.name }} {
state {{ keepalived_init_state | default('BACKUP') }}
interface {{ iface.interface | default(iface.name) }}
virtual_router_id 42
priority {{ keepalived_host_prio }}
advert_int 2
authentication {
auth_type PASS
auth_pass {{ iface.password | default(keepalived_password) }}
}
virtual_ipaddress {
{% for addr in iface.addresses %}
{{ addr }}
{% endfor %}
}
}
{% endfor %}
+3
View File
@@ -0,0 +1,3 @@
keepalived_os_supported: true
keepalived_packages:
- keepalived
+1
View File
@@ -0,0 +1 @@
keepalived_os_supported: false