Skip to content

Commit ce719a1

Browse files
committed
use inventory_hostname instead of ansible_hostname
1 parent 93ff879 commit ce719a1

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

@@ -35,11 +35,11 @@
3535
# These tasks run after the roles:
3636
post_tasks:
3737
- name: Enable the server in haproxy
38-
shell: echo "enable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats
38+
shell: echo "enable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
3939
delegate_to: "{{ item }}"
4040
with_items: groups.lbservers
4141

4242
- name: re-enable nagios alerts
43-
nagios: action=enable_alerts host={{ ansible_hostname }} services=webserver
43+
nagios: action=enable_alerts host={{ inventory_hostname }} services=webserver
4444
delegate_to: "{{ item }}"
4545
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)