-
Notifications
You must be signed in to change notification settings - Fork 6
/
sagenv-tools-playbooks-run-concurrent.yaml
65 lines (57 loc) · 2.72 KB
/
sagenv-tools-playbooks-run-concurrent.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- hosts: localhost
gather_facts: true
vars:
playbooks_extravars_filepath:
playbooks_extravars:
playbooks_tags:
playbooks_skip_tags:
playbooks_dir: "./playbooks"
playbooks_dirproject_name:
playbooks_names: []
tasks:
- name: Clear the ansible params fact
set_fact:
playbook_params: []
- name: Print the params
debug:
msg:
- "Running webmethods producct provisoning with:"
- "playbooks_extravars_filepath = {{ playbooks_extravars_filepath | default('undefined') }}"
- "playbooks_extravars = {{ playbooks_extravars | default('undefined') }}"
- "playbooks_tags = {{ playbooks_tags | default('undefined') }}"
- "playbooks_skip_tags = {{ playbooks_skip_tags | default('undefined') }}"
- "playbooks_dir = {{ playbooks_dir | default('undefined') }}"
- "playbooks_dirproject_name = {{ playbooks_dirproject_name | default('undefined') }}"
- "playbooks_names = {{ playbooks_names | default('undefined') }}"
- name: append extra-vars file path {{ playbooks_extravars_filepath }} to the playbook_params list
set_fact:
playbook_params: "{{ playbook_params }} + [ '--extra-vars \"@{{ playbooks_extravars_filepath }}\"' ]"
when: playbooks_extravars_filepath is defined and playbooks_extravars_filepath != ""
- name: append tags {{ playbooks_tags }} to the playbook_params list
set_fact:
playbook_params: "{{ playbook_params }} + [ '--tags {{ playbooks_tags }}' ]"
when: playbooks_tags is defined and playbooks_tags != ""
- name: append skip_tags {{ playbooks_skip_tags }} to the playbook_params list
set_fact:
playbook_params: "{{ playbook_params }} + [ '--skip-tags {{ playbooks_skip_tags }}' ]"
when: playbooks_skip_tags is defined and playbooks_skip_tags != ""
- name: Running ansible-playbook {{ playbooks_dir }}/{{ playbooks_dirproject_name }}/{{ item }}.yaml
shell: ansible-playbook {{ playbooks_dir }}/{{ playbooks_dirproject_name }}/{{ item }}.yaml {{ playbook_params|join(' ') }}
async: 4800
poll: 0
with_items: "{{ playbooks_names }}"
register: run_plays
- name: Check status of the parallel playbook executions
async_status:
jid: "{{ run_plays.results[item.0].ansible_job_id }}"
register: job_results
until: job_results.finished
with_indexed_items: "{{ playbooks_names }}"
retries: 200
delay: 24
- name: Copy command result to the server
copy:
content: "{{ job_results.results[item.0].stdout_lines | join('\n') }}"
dest: "{{ ansible_env.HOME }}/{{ playbooks_dirproject_name }}-{{ item.1 | replace('/','-') }}.out"
with_indexed_items: "{{ playbooks_names }}"