---
- hosts: localhost
  gather_facts: no
  tasks:
    - name: add ssh key to openstack tenant
      local_action:
        module: nova_keypair
        name: "{{ ansible_ssh_key }}"
        public_key: "{{ ansible_ssh_pubkey }}"
        auth_url: "{{ lookup('env', 'OS_AUTH_URL') }}"
        login_username: "{{ lookup('env','OS_USERNAME') }}"
        login_password: "{{ lookup('env','OS_PASSWORD') }}"
        login_tenant_name: "{{ lookup('env', 'OS_TENANT_NAME') }}"
        state: present

---
- hosts: all
  connection: localhost
  gather_facts: no
  tasks:
    - name: add ssh key to openstack tenant
      local_action:
        module: nova_keypair
        name: "{{ ansible_ssh_key }}"
        public_key: "{{ ansible_ssh_pubkey }}"
        auth_url: "{{ os_auth_url }}"
        login_username: "{{ lookup('env','OS_USERNAME') }}"
        login_password: "{{ lookup('env','OS_PASSWORD') }}"
        login_tenant_name: "{{ os_tenant_name }}"
        state: present

Switch from OpenStack env to ansible variables
Switch from OpenStack env to ansible variables

Run on all hosts to account for multiple OpenStack Regions
