pve_tests/ansible/task-number-playbook.yaml

27 lines
626 B
YAML

---
- name: Save global variables
hosts: all_vms
vars_prompt:
- name: task_number
private: no
when: not task_number
tasks:
- name: Add dummy host to save global vars
run_once: true
add_host:
name: DUMMY_GLOBAL_VARS
task_number: "{{ task_number }}"
- name: Maybe install apt-repo
hosts: all_vms
tasks:
- name: Install apt-repo
apt_rpm:
name: apt-repo
update_cache: true
when: hostvars.DUMMY_GLOBAL_VARS.task_number
- name: Add task
apt_repo:
repo: "{{ hostvars.DUMMY_GLOBAL_VARS.task_number }}"
when: hostvars.DUMMY_GLOBAL_VARS.task_number