@@ -73,17 +73,26 @@ def add_plugin_args(self):
73
73
action = conf_action (self ._config .plugins [self .full_name ]),
74
74
help = 'Used when generating/copying certs for use with Puppet Master' )
75
75
76
+ def _get_config_value (self , name , default ):
77
+ config = self ._config .plugins [self .full_name ]
78
+
79
+ if config .get (name ):
80
+ return config .get (name )
81
+
82
+ self ._config .plugins [self .full_name ].__setattr__ (name , default )
83
+ return default
84
+
76
85
def _store_package_metadata (self ):
77
86
""
78
-
87
+
79
88
def _provision_package (self ):
80
89
""
81
-
90
+
82
91
def _pre_chroot_block (self ):
83
92
log .debug ('Starting _pre_chroot_block' )
84
93
context = self ._config .context
85
94
config = self ._config
86
-
95
+
87
96
log .debug ("Setting metadata release to {0}" .format (time .strftime ("%Y%m%d%H%M" )))
88
97
context .package .attributes = {'name' : '' , 'version' : 'puppet' , 'release' : time .strftime ("%Y%m%d%H%M" ) }
89
98
@@ -93,8 +102,8 @@ def _pre_chroot_block(self):
93
102
self ._set_up_puppet_manifests (context .package .arg )
94
103
95
104
def _set_up_puppet_certs (self , pem_file_name ):
96
- certs_dir = self ._config . context . puppet . get ('puppet_certs_dir' , os .path .join ('/var' ,'lib' ,'puppet' ,'ssl' ,'certs' ))
97
- private_keys_dir = self ._config . context . puppet . get ('puppet_private_keys_dir' ,os .path .join ('/var' ,'lib' ,'puppet' ,'ssl' ,'private_keys' ))
105
+ certs_dir = self ._get_config_value ('puppet_certs_dir' , os .path .join ('/var' ,'lib' ,'puppet' ,'ssl' ,'certs' ))
106
+ private_keys_dir = self ._config . self . _get_config_value ('puppet_private_keys_dir' ,os .path .join ('/var' ,'lib' ,'puppet' ,'ssl' ,'private_keys' ))
98
107
99
108
mkdir_p (self ._distro ._mountpoint + certs_dir )
100
109
mkdir_p (self ._distro ._mountpoint + private_keys_dir )
@@ -150,7 +159,7 @@ def _rm_puppet_certs_dirs(self, certs_dir = '/var/lib/puppet/ssl'):
150
159
151
160
def _escaped_puppet_args (self ):
152
161
import re
153
- return re .sub ('\s' ,'\ ' , self ._config . context . puppet . get ('puppet_args' , '' ))
162
+ return re .sub ('\s' ,'\ ' , self ._get_config_value ('puppet_args' , '' ))
154
163
155
164
def provision (self ):
156
165
"""
@@ -175,7 +184,7 @@ def provision(self):
175
184
self ._puppet_run_mode = 'master'
176
185
177
186
self ._pre_chroot_block ()
178
-
187
+
179
188
log .debug ('Entering chroot at {0}' .format (self ._distro ._mountpoint ))
180
189
with Chroot (self ._distro ._mountpoint ):
181
190
if self ._distro ._name is 'redhat' :
@@ -191,7 +200,7 @@ def provision(self):
191
200
192
201
if self ._puppet_run_mode is 'master' :
193
202
log .info ('Running puppet agent' )
194
- result = puppet_agent ( escaped_args , context .package .arg , context . puppet . get ('puppet_master' , socket .gethostname ()) )
203
+ result = puppet_agent ( escaped_args , context .package .arg , self . _get_config_value ('puppet_master' , socket .gethostname ()) )
195
204
self ._rm_puppet_certs_dirs ()
196
205
elif self ._puppet_run_mode is 'apply' :
197
206
if self ._puppet_apply_file is '' :
0 commit comments