Skip to content

Instantly share code, notes, and snippets.

@arubdesu
Last active June 14, 2016 19:44
Show Gist options
  • Select an option

  • Save arubdesu/8cd7e5bae7c190ccedac82f0092439aa to your computer and use it in GitHub Desktop.

Select an option

Save arubdesu/8cd7e5bae7c190ccedac82f0092439aa to your computer and use it in GitHub Desktop.

Revisions

  1. arubdesu revised this gist Jun 14, 2016. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions bootstrap_pupppetcerts.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    #!/usr/bin/python
    """bootstraps puppet, which gets munki ready for SSL,
    and runs the munki function that shoves puppet's CA into the sys keychain"""
    and runs the munki function that shoves puppet's CA into the sys keychain.
    Assumes this is at /Library/MMCSupport/bootstrap_puppet.py,
    and called by outset(github.com/chilcote/outset)'s boot-every option"""

    import os
    import shutil
    @@ -27,7 +29,7 @@ def main():
    print "\nPuppet bootstrap should be complete, seeding certs"
    # Uses munkilib's keychain module to inject into system keychain using puppet-set prefs
    keychain.add_ca_certs_to_system_keychain()
    shutil.move(sys.argv[0], '/Library/MMCSupport/bootstrap_puppet.py'
    shutil.move(sys.argv[0], '/Library/MMCSupport/bootstrap_puppet.py')
    sys.exit(code)

    if __name__ == '__main__':
  2. arubdesu created this gist Jun 14, 2016.
    34 changes: 34 additions & 0 deletions bootstrap_pupppetcerts.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    #!/usr/bin/python
    """bootstraps puppet, which gets munki ready for SSL,
    and runs the munki function that shoves puppet's CA into the sys keychain"""

    import os
    import shutil
    import subprocess
    import sys
    import time

    sys.path.append('/usr/local/munki/munkilib')
    import keychain

    def main():
    """gimme some main"""
    print "Starting puppet bootstrap process\n"
    munkipath = '/Users/Shared/.com.googlecode.munki.checkandinstallatstartup'
    puppet_cmd = ['/opt/puppetlabs/bin/puppet', 'agent', '-t']
    while True:
    if os.path.exists(munkipath):
    print 'Sleeping another 15...'
    time.sleep(15)
    else:
    break
    print "Enough sleep, running puppet bootstrap"
    code = subprocess.check_call(puppet_cmd)
    print "\nPuppet bootstrap should be complete, seeding certs"
    # Uses munkilib's keychain module to inject into system keychain using puppet-set prefs
    keychain.add_ca_certs_to_system_keychain()
    shutil.move(sys.argv[0], '/Library/MMCSupport/bootstrap_puppet.py'
    sys.exit(code)

    if __name__ == '__main__':
    main()