-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexternals.html
138 lines (121 loc) · 5.63 KB
/
externals.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/stylesheets/stylesheet.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/stylesheets/pygment_trac.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/stylesheets/print.css" media="print" />
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>tpkg: Application packaging and deployment</title>
</head>
<body>
<div id="container">
<div class="sidebar">
<strong>Documents:</strong>
<ul>
<li><a href="get_started.html">Get started</a></li>
<li><a href="configure.html">Configure</a></li>
<li><a href="package.html">Package</a></li>
<li><a href="third_party.html">Package 3rd party apps</a></li>
<li><a href="deploy.html">Deploy</a></li>
<li><a href="package_server.html">Package server</a></li>
<li><a href="reporting_server.html">Reporting server</a></li>
<li><a href="production.html">Production</a></li>
<li><a href="externals.html">Externals</a></li>
<li><a href="faq.html">FAQ</a></li>
<li><a href="develop/">Develop</a></li>
</ul>
</div>
<div class="center">
<div class="inner">
<header>
<h1>tpkg</h1>
<h2>Application packaging and deployment</h2>
</header>
<hr>
<section id="main_content">
<p>
tpkg has a mechanism for packages to make requests to other applications on
the system where a package is installed. The package specifies the name of
the external hook to call and some data to send to that hook. When the
package is installed, upgraded or removed the external hook script is executed
and passed the name of the package, the action being performed, and the data
associated with that hook in the package. Tpkg includes some example scripts
and you can write additional scripts that are appropriate for your environment.
</p>
<p>
The primary use case for this feature is to integrate with an OS configuration
management tool like etch, puppet or cfengine. The tpkg for an application
should encapsulate all files and configuration needed for the application to
run on top of a generic base system in your environment. This may include OS
configuration items like user accounts, kernel settings or NFS mounts. If
your OS configuration tool is managing those settings your package may need to
interact with it to get those configuration items activated. If your package
tried to manipulate those settings directly (modifying /etc/passwd directly,
for example) the OS configuration management tool may undo those changes,
depending on how it is configured. With the externals feature you can create
an arrangement where those configuration changes are submitted as requests to
the OS config tool, which is then called to activate those requests.
</p>
<h2>Package Configuration</h2>
<p>
The general format of the externals section in a package's tpkg.yml file is:
</p>
<pre>
externals:
- name: user
data: myuser
- name: nfs
datafile: nfsmountsfile
- name: sysctl
datascript: ./calculate_kernel_memory_settings</pre>
<p>
The name field specifies the name of the external to call. The data to pass to
the external can either be specified inline via the "data" field, in an
external file referenced via the "datafile" field, or an external script
referenced via the "datascript" field. The script for datascript can be any
form of valid executable, it should be contained in your package directory
structure, and referenced with a path relative to the top of the package
directory structure (i.e. the directory where tpkg.yml lives). Whatever your
datascript script outputs will be fed to the tpkg external script. We envision
this being particularly useful in calculating kernel parameters based on
things like the amount of physical memory in a system.
</p>
<h2>External Scripts</h2>
<p>
The external scripts live in the /usr/lib/tpkg/externals directory. So using
the example above with the external named "user" that would trigger a call to
/usr/lib/tpkg/externals/user. That script will be passed the package filename
as the first command line argument and the operation being performed (either
'install' or 'remove') as the second argument. The data associated with the
external will be passed to the script on stdin. Any output is ignored, as is
the exit value of the script. Note that an upgrade is implemented in tpkg as
a remove of the old version followed by an install of the new version, so
externals are called as appropriate. I.e. externals do not need to implement
an 'upgrade' operation.
</p>
<p>
Note that if your script does not need the data passed in on stdin you should
dump it to /dev/null. Otherwise you might intermittently generate a SIGPIPE
error in tpkg if your script exits before tpkg finishes writing data to it.
Something like <tt>cat > /dev/null</tt> at an appropriate place in your
script should do the trick.
</p>
<p>
The TPKG_HOME environment variable will be set with the tpkg base directory,
/opt/tpkg by default, in the environment of external scripts when they are
executed.
</p>
</section>
</div>
</div>
<section id="downloads" class="clearfix">
<a href="https://github.com/tpkg" id="view-on-github" class="button"><span>View on GitHub</span></a>
</section>
</div>
</body>
</html>