Graph DB: upload hiera yaml configs for puppet
This commit is contained in:
parent
d90a5bee8e
commit
88462db2fc
@ -1,7 +1,7 @@
|
||||
$resource = hiera($::resource_name)
|
||||
|
||||
$port = "${resource['input']['port']['value']}"
|
||||
$management_port = "${resource['input']['management_port']['value']}"
|
||||
$port = "${resource['input']['port']}"
|
||||
$management_port = "${resource['input']['management_port']}"
|
||||
|
||||
class { '::rabbitmq':
|
||||
service_manage => true,
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from solar.core.log import log
|
||||
from solar.core.handlers.base import TempFileHandler
|
||||
@ -98,6 +99,8 @@ class Puppet(TempFileHandler):
|
||||
action_file = self._compile_action_file(resource, action_name)
|
||||
log.debug('action_file: %s', action_file)
|
||||
|
||||
self.upload_hiera_resource(resource)
|
||||
|
||||
self.upload_manifests(resource)
|
||||
|
||||
self.prepare_templates_and_scripts(resource, action_file, '')
|
||||
@ -111,7 +114,7 @@ class Puppet(TempFileHandler):
|
||||
'FACTER_resource_name': resource.name,
|
||||
},
|
||||
use_sudo=True,
|
||||
warn_only=True,
|
||||
warn_only=True
|
||||
)
|
||||
# 0 - no changes, 2 - successfull changes
|
||||
if cmd.return_code not in [0, 2]:
|
||||
@ -126,6 +129,20 @@ class Puppet(TempFileHandler):
|
||||
|
||||
return p.directory
|
||||
|
||||
def upload_hiera_resource(self, resource):
|
||||
with open('/tmp/puppet_resource.yaml', 'w') as f:
|
||||
f.write(yaml.dump({
|
||||
resource.name: resource.to_dict()
|
||||
}))
|
||||
|
||||
self.transport_sync.copy(
|
||||
resource,
|
||||
'/tmp/puppet_resource.yaml',
|
||||
'/etc/puppet/hieradata/{}.yaml'.format(resource.name),
|
||||
use_sudo=True
|
||||
)
|
||||
self.transport_sync.sync_all()
|
||||
|
||||
def upload_manifests(self, resource):
|
||||
if 'forge' in resource.args and resource.args['forge']:
|
||||
self.upload_manifests_forge(resource)
|
||||
|
@ -114,6 +114,12 @@ class Resource(object):
|
||||
i.name: i for i in self.db_obj.inputs.value
|
||||
}
|
||||
|
||||
def to_dict(self):
|
||||
ret = self.db_obj.to_dict()
|
||||
ret['input'] = self.args
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def load(name):
|
||||
r = orm.DBResource.load(name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user