Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: hiera/install-precise.py

Issue 4810150141493248: Issue 122 - Puppet ENC via Hiera (Closed)
Patch Set: 112 - Puppet ENC via Hiera Created Oct. 8, 2014, 3:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: hiera/install-precise.py
===================================================================
new file mode 100755
--- /dev/null
+++ b/hiera/install-precise.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+import base64
+import distutils.spawn
+import io
+import os
+import subprocess
+import sys
+
+if distutils.spawn.find_executable('puppet') \
+ and distutils.spawn.find_executable('hiera'):
+ sys.exit(os.EX_OK)
+
+PUPPETLABS_SOURCES = '''
+deb http://apt.puppetlabs.com precise main
+deb-src http://apt.puppetlabs.com precise main'''
+
+PUPPETLABS_PREFS = '''
+# Puppetlabs packages (e.g. hiera) would attempt to install a puppet 3.x
+# or later release (which is not available in precise) if not pinned here
+Package: puppet puppet-common
+Pin: version 2.7.11-*
+Pin-Priority: 1000'''
+
+PUPPETLABS_GPG_KEY = '''
+mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6bfUBQeaZ8rh6N
+4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg5iZaz+brUZlFk/MyJ0Yz//VQ
+68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cY
+yrw5KfBvFI3cHDdBqrEJQKwKeLKYGHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BW
+UzgJv6ztPe9imqpHPpp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+
+Fd0vVMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0Nc5FQweU
+tH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m9VAkugVI
+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
+
+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.
+decoded_key = base64.b64decode(PUPPETLABS_GPG_KEY)
+handle.communicate(decoded_key)
+
+with io.open('/etc/apt/sources.list.d/puppetlabs.list', 'wb') as handle:
+ handle.write(PUPPETLABS_SOURCES)
+
+with io.open('/etc/apt/preferences.d/puppetlabs', 'wb') as handle:
+ handle.write(PUPPETLABS_PREFS)
+
+subprocess.check_call(['apt-get', '-y', 'update'])
+subprocess.check_call(['apt-get', '-y', 'install', 'puppet'])
+subprocess.check_call(['apt-get', '-y', 'install', 'hiera-puppet'])
+
+if not os.path.exists('/etc/puppet/hiera.yaml'):
+ 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.
+ if os.path.exists(config):
+ os.symlink(config, '/etc/puppet/hiera.yaml')

Powered by Google App Engine
This is Rietveld