use inventory_hostname instead of ansible_hostname

pull/63/head
Tim Gerla 10 years ago
parent 93ff879e60
commit ce719a12cb
  1. 2
      lamp_haproxy/roles/haproxy/templates/haproxy.cfg.j2
  2. 8
      lamp_haproxy/rolling_update.yml
  3. 4
      language_features/upgraded_vars.yml

@ -35,5 +35,5 @@ backend app
{% endfor %}
balance {{ balance }}
{% for host in groups['webservers'] %}
server {{ hostvars[host].ansible_hostname }} {{ hostvars[host]['ansible_' + iface].ipv4.address }}:{{ httpd_port }}
server {{ host }} {{ hostvars[host]['ansible_' + iface].ipv4.address }}:{{ httpd_port }}
{% endfor %}

@ -18,12 +18,12 @@
# These are the tasks to run before applying updates:
pre_tasks:
- name: disable nagios alerts for this host webserver service
nagios: action=disable_alerts host={{ ansible_hostname }} services=webserver
nagios: action=disable_alerts host={{ inventory_hostname }} services=webserver
delegate_to: "{{ item }}"
with_items: groups.monitoring
- name: disable the server in haproxy
shell: echo "disable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats
shell: echo "disable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
delegate_to: "{{ item }}"
with_items: groups.lbservers
@ -35,11 +35,11 @@
# These tasks run after the roles:
post_tasks:
- name: Enable the server in haproxy
shell: echo "enable server myapplb/{{ ansible_hostname }}" | socat stdio /var/lib/haproxy/stats
shell: echo "enable server myapplb/{{ inventory_hostname }}" | socat stdio /var/lib/haproxy/stats
delegate_to: "{{ item }}"
with_items: groups.lbservers
- name: re-enable nagios alerts
nagios: action=enable_alerts host={{ ansible_hostname }} services=webserver
nagios: action=enable_alerts host={{ inventory_hostname }} services=webserver
delegate_to: "{{ item }}"
with_items: groups.monitoring

@ -11,7 +11,7 @@
- c
tasks:
- shell: echo hello {{ ansible_hostname.upper() }}
- debug: msg="hello {{ ansible_hostname.upper() }}"
- shell: echo match
when: 2 == 2
@ -19,7 +19,7 @@
- shell: echo no match
when: 2 == 2 + 1
- shell: echo {{ ansible_os_family }}
- debug: msg="{{ ansible_os_family }}"
- shell: echo {{ item }}
with_items: a_list