-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.yml
94 lines (86 loc) · 3.03 KB
/
build.yml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- name: build
hosts: controller
gather_facts: no
vars:
_build_clean: "{{ clean | default(false) }}"
_build_number: "{{ build_number | default(_build_date) }}"
_build_directory: "{{ build_directory | default('build') }}"
_build_version: "{{ version if version else _build_number }}"
_build_package_name: ansible-playbook-execute
tasks:
- set_fact:
_build_date: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S%3N') }}"
- name: clean _build directory
file:
path: "{{ _build_directory }}"
state: absent
when: _build_clean
vars:
diy_playbook_on_task_start_msg: cleaning...
- name: create _build directory
file:
path: "{{ _build_directory }}"
state: directory
vars:
diy_playbook_on_task_start_msg: building...
- name: set build
set_fact:
_build: "{{ _build_directory }}/{{ _build_package_name }}-{{ _build_number }}"
- name: create _build and base directories
file:
path: "{{ _build }}/{{ item }}"
state: directory
with_items:
- callback_plugins
- roles
- name: add artifacts
copy:
content: "{{ item.content | default(omit) }}"
src: "{{ item.src | default(omit) }}"
dest: "{{ item.dest }}"
with_items:
- src: callback_plugins/diy.py
dest: "{{ _build }}/callback_plugins/"
- src: "roles/execution_manager"
dest: "{{ _build }}/roles/"
- src: "roles/dependency_manager"
dest: "{{ _build }}/roles/"
- src: ansible.cfg
dest: "{{ _build }}/"
- src: controller.yml
dest: "{{ _build }}/"
- src: execute.yml
dest: "{{ _build }}/"
- src: kill.yml
dest: "{{ _build }}/"
- src: LICENSE
dest: "{{ _build }}/"
- content: |
name: execute
author: Trevor Highfill (@theque5t)
description: Ansible playbook that takes in executions in code, assembles their dependencies, and runs them asynchronously
company:
license: MIT
date: "{{ _build_date }}"
build: "{{ _build_number }}"
version: "{{ _build_version }}"
min_ansible_version:
source_repo: https://github.com/theque5t/ansible-playbook-execute
dest: "{{ _build }}/manifest.yml"
- name: package artifacts
archive:
path: "{{ _build }}/*"
dest: "{{ _build_directory }}/{{ _build_package_name }}-{{ _build_version }}.tar.gz"
format: gz
- name: package stat
stat:
path: "{{ _build_directory }}/{{ _build_package_name }}-{{ _build_version }}.tar.gz"
checksum_algorithm: sha256
register: _build_stat
- name: create package checksum
copy:
content: "{{ _build_stat.stat.checksum }}"
dest: "{{ _build_directory }}/{{ _build_package_name }}-{{ _build_version }}.tar.gz.sha256"
vars:
diy_runner_on_ok_msg: build successfull
diy_runner_on_ok_msg_color: green