---
- hosts: all
sudo: yes
tasks:
- name: register current play_hosts for later
ping:
register: play_hosts_all # this doesn't work obviously
- hosts: localhost
connection: local
sudo: yes
tasks:
- name: create keys/certs
command : pkitool {{ item }}
with_items: {{ play_hosts_all }}
- hosts: {{ play_hosts_all }}
sudo: yes
tasks:
- name: deploy key/cert/...
copy: src= ... dest= ...
# somehosts.yml
---
- hosts: all
sudo: yes
vars:
allhosts: "{{ hostvars.keys() }}"
tasks:
- name: all the current hosts
debug: var=allhosts
- hosts: localhost
connection: local
sudo: yes
tasks:
- name: allhosts is reset/empty because this is a new play
debug: var=allhosts
- name: hosts in all-group
debug: var="{{ item }}"
with_items: groups['all']
---
- hosts: all
sudo: yes
tasks:
- name:play_hosts
debug: var=play_hosts
when: current_host == "localhost"
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CADn%2BHsxi1Xc2-BPmxfese12yCrWviigwXS7XsMPxbCM6ey%2BoOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.