Skip to content

Commit deab84f

Browse files
committed
Merge pull request ansible#74 from tgerla/varsfixes
use inventory_hostname instead of ansible_hostname
2 parents 4da3696 + ce719a1 commit deab84f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lamp_haproxy/roles/haproxy/templates/haproxy.cfg.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ backend app
3535
{% endfor %}
3636
balance {{ balance }}
3737
{% for host in groups['webservers'] %}
38-
server {{ hostvars[host].ansible_hostname }} {{ hostvars[host]['ansible_' + iface].ipv4.address }}:{{ httpd_port }}
38+
server {{ host }} {{ hostvars[host]['ansible_' + iface].ipv4.address }}:{{ httpd_port }}
3939
{% endfor %}

lamp_haproxy/rolling_update.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
# These are the tasks to run before applying updates:
1919
pre_tasks:
2020
- name: disable nagios alerts for this host webserver service
21-
nagios: action=disable_alerts host={{ ansible_hostname }} services=webserver
21+
nagios: action=disable_alerts host={{ inventory_hostname }} services=webserver
2222
delegate_to: "{{ item }}"
2323
with_items: groups.monitoring
2424

2525
- name: disable the server in haproxy
26-
shell: echo "disable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats
26+
shell: echo "disable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
2727
delegate_to: "{{ item }}"
2828
with_items: groups.lbservers
2929

@@ -38,11 +38,11 @@
3838
wait_for: host={{ inventory_hostname }} port=80 state=started timeout=80
3939

4040
- name: Enable the server in haproxy
41-
shell: echo "enable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats
41+
shell: echo "enable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
4242
delegate_to: "{{ item }}"
4343
with_items: groups.lbservers
4444

4545
- name: re-enable nagios alerts
46-
nagios: action=enable_alerts host={{ ansible_hostname }} services=webserver
46+
nagios: action=enable_alerts host={{ inventory_hostname }} services=webserver
4747
delegate_to: "{{ item }}"
4848
with_items: groups.monitoring

language_features/upgraded_vars.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
- c
1212

1313
tasks:
14-
- shell: echo hello {{ ansible_hostname.upper() }}
14+
- debug: msg="hello {{ ansible_hostname.upper() }}"
1515

1616
- shell: echo match
1717
when: 2 == 2
1818

1919
- shell: echo no match
2020
when: 2 == 2 + 1
2121

22-
- shell: echo {{ ansible_os_family }}
22+
- debug: msg="{{ ansible_os_family }}"
2323

2424
- shell: echo {{ item }}
2525
with_items: a_list

0 commit comments

Comments
 (0)