Skip to content

Commit 00ca052

Browse files
committed
Merge pull request alphagov#185 from alphagov/add-task-sign-puppet-certs
Add a task to sign Puppet certificates
2 parents df689ba + 60ceb29 commit 00ca052

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

puppet.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from fabric.api import *
2+
from time import sleep
23

34

45
def puppet(*args):
@@ -45,3 +46,15 @@ def lookup_hieradata(key):
4546
config_file = '{0}/hiera.yml'.format(puppet_directory)
4647
variables = '::environment=production ::lsbdistcodename=precise ::settings::manifestdir={0}/manifests'.format(puppet_directory)
4748
run('hiera --config {0} {1} {2}'.format(config_file, key, variables))
49+
50+
51+
@task
52+
@hosts('puppetmaster-1.management')
53+
def sign_certificates():
54+
"""Sign Puppet certificates on the Puppetmaster when launching machines"""
55+
print('Signing certificates in a loop. Cancel this command to stop signing certificates.')
56+
while True:
57+
# 24 is the exit code that Puppet returns when there are no waiting certificate requests to sign
58+
with settings(ok_ret_codes=[0, 24]):
59+
sudo('puppet cert sign --all')
60+
sleep(10)

0 commit comments

Comments
 (0)