-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
split keepalived config and refactoring #203
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ba46e01
split keepalived config and refactoring
Kariton c3a308a
Ensure instance.vips_excluded is not empty #195
Kariton 2079e31
Add support for accept/no_accept for instances. #176
Kariton 1cf89c6
fix accept/no_accept for instances missing tag
Kariton bcb871f
fix some stuff...
Kariton 359a456
fix accept/no_accept for instances missing tag II
Kariton f437e89
Add support for vrrp_track_file and track_files #140 (#2)
Kariton 1d30d9b
fix hardcoded filepath
Kariton 88369ea
remove fqcn-builtins exclude from ansible-lint from #199
Kariton 2512370
add ability to flush_configuration
Kariton f10bd8e
replace my vips_excluded is iterable with length
Kariton 5a05ff2
FQCN ansible.netcommon.ipaddr
Kariton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
|
||
- name: Configure keepalived | ||
ansible.builtin.template: | ||
src: keepalived.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/{{ keepalived_config_base_file }}" | ||
mode: "0640" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived script | ||
ansible.builtin.template: | ||
src: keepalived_script.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/scripts/{{ item.key }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_scripts is defined | ||
- item.value.state | d('present') == 'present' | ||
loop: "{{ keepalived_scripts | dict2items }}" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived track files | ||
ansible.builtin.template: | ||
src: keepalived_track_files.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/track_files/{{ item.key }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_track_files is defined | ||
- item.value.state | d('present') == 'present' | ||
loop: "{{ keepalived_track_files | dict2items }}" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived sync_groups | ||
ansible.builtin.template: | ||
src: keepalived_sync_groups.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/sync_groups/{{ item.key }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_sync_groups is defined | ||
- item.value.state | d('present') == 'present' | ||
loop: "{{ keepalived_sync_groups | dict2items }}" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived instances | ||
ansible.builtin.template: | ||
src: keepalived_instances.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/instances/{{ item.key }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_instances is defined | ||
- item.value.state | d('present') in ['present', 'MASTER', 'BACKUP'] | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived service groups | ||
ansible.builtin.template: | ||
src: keepalived_virtual_server_groups.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/groups/{{ item.name }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_virtual_server_groups is defined | ||
- item.name.state | d('present') == 'present' | ||
loop: "{{ keepalived_virtual_server_groups }}" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived single services | ||
ansible.builtin.template: | ||
src: keepalived_single_services.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/services/single_{{ item.ip | replace('.', '_') }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_virtual_servers is defined | ||
- item.ip.state | d('present') == 'present' | ||
loop: "{{ keepalived_virtual_servers }}" | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Configure keepalived group services | ||
ansible.builtin.template: | ||
src: keepalived_group_services.conf.j2 | ||
dest: "{{ keepalived_config_directory_path }}/services/group_{{ item.name }}.conf" | ||
mode: "0640" | ||
when: | ||
- keepalived_virtual_server_groups is defined | ||
- item.name.state | d('present') == 'present' | ||
loop: "{{ keepalived_virtual_server_groups }}" | ||
notify: | ||
- reload keepalived |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
|
||
- name: Dropping the tracking scripts | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_check_script }}" | ||
dest: "{{ item.value.dest_check_script | default(item.value.check_script) }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_scripts | dict2items | default('{}') }}" | ||
when: item.value.src_check_script is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the general notification scripts | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_script }}" | ||
dest: "{{ item.value.notify_script }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_sync_groups | dict2items }}" | ||
when: item.value.src_notify_script is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for switching to master | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_master }}" | ||
dest: "{{ item.value.notify_master }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_sync_groups | dict2items }}" | ||
when: item.value.src_notify_master is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for switching to backup | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_backup }}" | ||
dest: "{{ item.value.notify_backup }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_sync_groups | dict2items }}" | ||
when: item.value.src_notify_backup is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for failures | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_fault }}" | ||
dest: "{{ item.value.notify_fault }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_sync_groups | dict2items }}" | ||
when: item.value.src_notify_fault is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the general notification scripts (instances) | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_script }}" | ||
dest: "{{ item.value.notify_script }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
when: item.value.src_notify_script is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for switching to master (instances) | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_master }}" | ||
dest: "{{ item.value.notify_master }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
when: item.value.src_notify_master is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for lower priority master case (instances) | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_master_rx_lower_pri }}" | ||
dest: "{{ item.value.notify_master_rx_lower_pri }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
when: item.value.src_notify_master_rx_lower_pri is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for switching to backup (instances) | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_backup }}" | ||
dest: "{{ item.value.notify_backup }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
when: item.value.src_notify_backup is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for stopping vrrp (instances) | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_stop }}" | ||
dest: "{{ item.value.notify_stop }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
when: item.value.src_notify_stop is defined | ||
notify: | ||
- reload keepalived | ||
|
||
- name: Dropping the notification scripts for failures (instances) | ||
ansible.builtin.copy: | ||
src: "{{ item.value.src_notify_fault }}" | ||
dest: "{{ item.value.notify_fault }}" | ||
mode: "0755" | ||
loop: "{{ keepalived_instances | dict2items }}" | ||
when: item.value.src_notify_fault is defined | ||
notify: | ||
- reload keepalived |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not introduce a variable to flush the configuration, instead, the state of the other variables should help us figure out what to do (the variable contains the full state). If truly impossible to do, then the deployer can just run an ad-hoc ansible command to clean up (and not need an extra variable).
The idea of the previous config was that if you were to change it, you would never have something laying around that cause an issue of misconfiguration.