Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 import base64 | |
3 import distutils.spawn | |
4 import io | |
5 import os | |
6 import subprocess | |
7 import sys | |
8 | |
9 if distutils.spawn.find_executable('puppet') \ | |
10 and distutils.spawn.find_executable('hiera'): | |
11 sys.exit(os.EX_OK) | |
12 | |
13 PUPPETLABS_SOURCES = ''' | |
14 deb http://apt.puppetlabs.com precise main | |
15 deb-src http://apt.puppetlabs.com precise main''' | |
16 | |
17 PUPPETLABS_PREFS = ''' | |
18 # Puppetlabs packages (e.g. hiera) would attempt to install a puppet 3.x | |
19 # or later release (which is not available in precise) if not pinned here | |
20 Package: puppet puppet-common | |
21 Pin: version 2.7.11-* | |
22 Pin-Priority: 1000''' | |
23 | |
24 PUPPETLABS_GPG_KEY = ''' | |
25 mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6bfUBQeaZ8rh6N | |
26 4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg5iZaz+brUZlFk/MyJ0Yz//VQ | |
27 68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cY | |
28 yrw5KfBvFI3cHDdBqrEJQKwKeLKYGHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BW | |
29 UzgJv6ztPe9imqpHPpp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+ | |
30 Fd0vVMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0Nc5FQweU | |
31 tHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiIwrjhMQQOOSZOb3vBRvBZ | |
32 NnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCNNlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiI | |
33 TJvh9CTg+k3wEmiaGz65w9jRl9ny2gElf4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgM | |
34 s2q25vWhygsmUQARAQABtEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVs | |
35 ZWFzZSBLZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAIbAwYLCQgHAwIGFQgCCQoL | |
36 BBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gcknii | |
37 n3+5ooz67hSr8miGBfK4eocqQ0H7bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton | |
38 2AZryV7vUADreYz44B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE | |
39 32gXvSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0jIq2V77w | |
40 fmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863YZQ0ZBe+Xyf5OI33+y+Mr | |
41 y+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4 | |
42 /FSiCw0HvX01epcersyun3xxPkRIjwwRM9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eor | |
43 VQbqGx0ruu/W2m5/JpUfREsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m | |
44 /Unacm5yDHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAkugVI | |
45 B2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYWwAgAD''' | |
Wladimir Palant
2014/11/17 16:43:36
https://pgp.mit.edu/pks/lookup?op=get&search=0x105
mathias
2014/11/27 00:30:18
In fact I do not recall us discussing to use the s
| |
46 | |
47 handle = subprocess.Popen(['apt-key', 'add', '-'], stdin=subprocess.PIPE) | |
Wladimir Palant
2014/11/17 16:43:36
I was already considering asking for that handle t
mathias
2014/11/27 00:30:18
Done.
| |
48 decoded_key = base64.b64decode(PUPPETLABS_GPG_KEY) | |
49 handle.communicate(decoded_key) | |
50 | |
51 with io.open('/etc/apt/sources.list.d/puppetlabs.list', 'wb') as handle: | |
52 handle.write(PUPPETLABS_SOURCES) | |
53 | |
54 with io.open('/etc/apt/preferences.d/puppetlabs', 'wb') as handle: | |
55 handle.write(PUPPETLABS_PREFS) | |
56 | |
57 subprocess.check_call(['apt-get', '-y', 'update']) | |
58 subprocess.check_call(['apt-get', '-y', 'install', 'puppet']) | |
59 subprocess.check_call(['apt-get', '-y', 'install', 'hiera-puppet']) | |
60 | |
61 if not os.path.exists('/etc/puppet/hiera.yaml'): | |
62 config = os.path.dirname(__file__) + '/hiera.yaml' | |
Wladimir Palant
2014/11/17 16:43:36
Please use os.path.join() instead of string concat
mathias
2014/11/27 00:30:18
Done.
| |
63 if os.path.exists(config): | |
64 os.symlink(config, '/etc/puppet/hiera.yaml') | |
OLD | NEW |