Merge "Change the variable name play_hosts to ansible_play_hosts"

This commit is contained in:
Jenkins 2017-06-26 14:07:21 +00:00 committed by Gerrit Code Review
commit f0d4088a72
2 changed files with 11 additions and 11 deletions

View File

@ -41,15 +41,15 @@ keepalived_scripts:
# If you have more than 5 keepalived nodes, you should build your own script
# (handling master and backups servers), and replace in keepalived_instances:
# priority: "{{ ((play_hosts|length-play_hosts.index(inventory_hostname))*100)-((play_hosts|length-play_hosts.index(inventory_hostname))*50) }}"
# priority: "{{ ((ansible_play_hosts|length-ansible_play_hosts.index(inventory_hostname))*100)-((ansible_play_hosts|length-ansible_play_hosts.index(inventory_hostname))*50) }}"
# by
# priority: "{{ (play_hosts.index(inventory_hostname) == 0) | ternary('100','50') }}"
# priority: "{{ (ansible_play_hosts.index(inventory_hostname) == 0) | ternary('100','50') }}"
keepalived_instances:
external:
interface: "{{ haproxy_keepalived_external_interface | default(management_bridge) }}"
state: "{{ (play_hosts.index(inventory_hostname) == 0) | ternary('MASTER', 'BACKUP') }}"
state: "{{ (ansible_play_hosts.index(inventory_hostname) == 0) | ternary('MASTER', 'BACKUP') }}"
virtual_router_id: "{{ haproxy_keepalived_external_virtual_router_id | default ('10') }}"
priority: "{{ ((play_hosts|length-play_hosts.index(inventory_hostname))*100)-((play_hosts|length-play_hosts.index(inventory_hostname))*50) }}"
priority: "{{ ((ansible_play_hosts|length-ansible_play_hosts.index(inventory_hostname))*100)-((ansible_play_hosts|length-ansible_play_hosts.index(inventory_hostname))*50) }}"
authentication_password: "{{ haproxy_keepalived_authentication_password }}"
vips:
- "{{ haproxy_keepalived_external_vip_cidr | default('169.254.1.1/24') }} dev {{ haproxy_keepalived_external_interface | default(management_bridge) }}"
@ -58,9 +58,9 @@ keepalived_instances:
- pingable_check_script
internal:
interface: "{{ haproxy_keepalived_internal_interface | default(management_bridge) }}"
state: "{{ (play_hosts.index(inventory_hostname) == 0) | ternary('MASTER', 'BACKUP') }}"
state: "{{ (ansible_play_hosts.index(inventory_hostname) == 0) | ternary('MASTER', 'BACKUP') }}"
virtual_router_id: "{{ haproxy_keepalived_internal_virtual_router_id | default ('11') }}"
priority: "{{ ((play_hosts|length-play_hosts.index(inventory_hostname))*100)-((play_hosts|length-play_hosts.index(inventory_hostname))*50) }}"
priority: "{{ ((ansible_play_hosts|length-ansible_play_hosts.index(inventory_hostname))*100)-((ansible_play_hosts|length-ansible_play_hosts.index(inventory_hostname))*50) }}"
authentication_password: "{{ haproxy_keepalived_authentication_password }}"
track_scripts:
- haproxy_check_script

View File

@ -26,21 +26,21 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
{{ (((period | int) / ((hosts | length) | int)) | int) | random }}
{%- endif -%}
{%- endmacro %}
{% for host in play_hosts %}
{% for host in ansible_play_hosts %}
{% if host == inventory_hostname %}
{% set minute_period = set_period(minute_start, minute_end, 59, 0) | int %}
{% set minute_offset = set_offset(minute_period, play_hosts) | int %}
{% set minute_offset = set_offset(minute_period, ansible_play_hosts) | int %}
{% set number_of_minute_jobs = (4 | int) %}
{% set m = normalise((((minute_period * loop.index) / loop.length) + ((minute_offset | int) / (number_of_minute_jobs | int))), minute_start, minute_end, 0, 59, minute_period) | int %}
{% set hour_period = set_period(hour_start, hour_end, 23, 0) | int %}
{% set hour_offset = set_offset(hour_period, play_hosts) | int %}
{% set hour_offset = set_offset(hour_period, ansible_play_hosts) | int %}
{% set number_of_hour_jobs = (3 | int) %}
{% set h = normalise((((hour_period * loop.index) / loop.length) + ((hour_offset | int) / (number_of_hour_jobs | int))), hour_start, hour_end, 0, 23, hour_period) | int %}
{% set day_of_week_period = set_period(day_of_week_start, day_of_week_end, 6, 0) | int %}
{% set day_of_week_offset = set_offset(day_of_week_period, play_hosts) | int %}
{% set day_of_week_offset = set_offset(day_of_week_period, ansible_play_hosts) | int %}
{% set dow = normalise((((day_of_week_period * loop.index) / loop.length) + (day_of_week_offset | int)), day_of_week_start, day_of_week_end, 0, 6, day_of_week_period) | int %}
{% set day_of_month_period = set_period(day_of_month_start, day_of_month_end, 28, 1) | int %}
{% set day_of_month_offset = set_offset(day_of_month_period, play_hosts) | int %}
{% set day_of_month_offset = set_offset(day_of_month_period, ansible_play_hosts) | int %}
{% set dom = normalise((((day_of_month_period * loop.index) / loop.length) + (day_of_month_offset | int)), day_of_month_start, day_of_month_end, 1, 28, day_of_month_period) | int %}
{{ m }} * * * * root cd / && run-parts --report /etc/cron.hourly
{{ normalise((m + (minute_period * 1 / (number_of_minute_jobs | int))), minute_start, minute_end, 0, 59, minute_period) }} {{ h }} * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )