Setting a global variable in a task

Is there a way to set a variable in a task such that it has global scope?
I want to do something like this:

  - hosts: all
    serial: 1
    vars:
      foo_first_host: True

    tasks:

      - name: pause after the first host (expect "skipping" for subsequent
        hosts)
        pause:
          prompt: Pausing after the first host; hit return to do the rest
        when: foo_first_host

      - set_fact:
          foo_first_host: False

The problem is that set_fact seems to set the variable only in the current
host, which means that when the next host runs, the variable isn't set any
more. http://docs.ansible.com/ansible/set_fact_module.html says it right
there: "Variables are set on a host-by-host basis just like facts
discovered by the setup module."

Is there some other way to do what I'm trying to do there? I can think of
some other ideas, like using add_host to add a host to a group, and test
if the group is empty, but that seems sort of hokey.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

you can still access it via hostvars[‘hostitwassetin’][‘foo_first_host’]

you can still access it via hostvars['hostitwassetin']['foo_first_host']

Ja, but how do I know (when I'm the second host) who the first host was?

In my actual use case, I'm doing things like restarting a cluster of
appservers, and I want to pause after the first, and then just do the rest
without further prompting (but one at a time, so I don't want the
(otherwise super cool) new serial: [1, "100%"] business).

FWIW, the add_host trick seems to work:

  - hosts: all
    serial: 1

    tasks:

      - debug: var=groups['foo_completed_hosts']

      - name: pause after the first host (expect "skipping" for subsequent hosts)
        pause:
          prompt: Pausing after the first host; hit return to do the rest
        when: "'foo_completed_hosts' not in groups"

      - add_host: name={{ inventory_hostname }} groups=foo_completed_hosts

So, if there's not a way to set a global variable, the add_host way seems ok.

                                      -Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.