forked from selesy/workstation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_from_archive.yml
139 lines (126 loc) · 4.05 KB
/
install_from_archive.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
# File: install_from_archive.yml
# These plays download and install an application distributed as an
# archive. Set the appropriate variables as follows:
#
# Required variables:
# -------- ---------
#
# key: The application's key. This value will determine the
# name of the directory (in /opt) where the application
# is finally installed.
#
# title: The application's formal name.
#
# version: This value indicates what version should be downloaded
# and is generally set in the "workstation_versions.yml"
# file and copied within the task's vars file.
#
# url: The URL where the application's installation archive can
# be downloaded.
#
# Optional variables:
# -------- ---------
#
# checksum: The URL of the file containing a checksum for the archive
# which will be downloaded by this playbook.
#
# archive_path: If the archive includes a path prefix for each file, This
# value allows the archive to be "relocated" to a directory
# named by the version. If this variable is empty, the
# archive path is assumed to be ".".
#
# desktop_file: If the application has a GUI, this variable should point
# to a template that will be completed and copied to
# /usr/share/applications. If this variable is empty,
# no templating is performed.
#
# executables: A list of the executables that should have symlinks placed
# into /usr/bin. If this variable is empty, no symlinks
# are created.
#
- name: "defines the archive variables above"
assert:
that:
- "key is defined"
- "title is defined"
- "url is defined"
- "version is defined"
# - name: "defines the github variables above"
# set_fact:
# subscript_vars:
# - name: "archive_path"
# required: false
# - name: "checksum"
# required: false
# - name: "desktop_file"
# required: false
# - name: "executables"
# required: false
# - name: "key"
# required: true
# - name: "title"
# required: true
# - name: "url"
# required: true
# - name: "version"
# required: true
# - name: "installation_directory"
# required: false
# - name: "final_directory"
# required: false
# - name: "archive_directory"
# required: false
# - include: "./require_subscript_vars.yml"
- name: "calculate the installation and final directories for {{ title }}"
set_fact:
installation_directory: "/opt/{{ key }}"
final_directory: "/opt/{{ key }}/{{ version }}"
- name: "calculate the archive's directory for {{ title }}"
set_fact:
archive_directory: "/opt/{{ key }}/{{ archive_path }}"
when: "archive_path is defined"
- name: "create a directory for {{ title }}"
file:
name: "{{ installation_directory }}"
state: "directory"
- name: "download and unarchive {{ title }}"
unarchive:
src: "{{ url }}"
dest: "{{ installation_directory }}"
remote_src: "yes"
creates: "{{ final_directory }}"
register: "unarchive_result"
- name: "move the archive file's base directory somewhere maintainable"
command: "mv {{ archive_directory }} {{ final_directory }}"
when: "unarchive_result is changed"
- name: "create a pretty symlink to the latest version"
file:
src: "{{ final_directory }}"
path: "{{ installation_directory }}/latest"
state: "link"
- name: "create symlinks to the {{ title }} executables"
file:
src: "{{ installation_directory }}/latest/{{ item }}"
dest: "/usr/bin/{{ item }}"
state: "link"
with_items: "{{ executables }}"
when: "executables is defined"
- name: "add a desktop launcher for {{ title }}"
template:
src: "{{ desktop_file }}"
dest: "/usr/share/applications"
when: "desktop_file is defined"
- name: "clears the archive variables above"
set_fact:
archive_path:
checksum:
desktop_file:
executables:
key:
title:
url:
version:
installation_directory:
final_directory:
archive_directory: