Implement library resource
This commit is contained in:
parent
39c5a34a3f
commit
a527e29151
@ -20,15 +20,15 @@ NETWORK_SCHEMA = {
|
||||
}
|
||||
|
||||
NETWORK_METADATA = yaml.load("""
|
||||
node-1:
|
||||
solar-dev1:
|
||||
uid: '1'
|
||||
fqdn: node-1
|
||||
fqdn: solar-dev1
|
||||
network_roles:
|
||||
ceph/public: 10.0.0.3
|
||||
ceph/replication: 10.0.0.3
|
||||
node_roles:
|
||||
- ceph-mon
|
||||
name: node-1
|
||||
name: solar-dev1
|
||||
|
||||
""")
|
||||
|
||||
@ -38,17 +38,20 @@ def deploy():
|
||||
resources = vr.create('nodes', 'templates/nodes.yaml', {'count': 1})
|
||||
first_node = next(x for x in resources if x.name.startswith('node'))
|
||||
|
||||
ceph_mon = vr.create('ceph_mon1', 'resources/ceph_mon',
|
||||
{'storage': STORAGE,
|
||||
'keystone': KEYSTONE,
|
||||
'network_scheme': NETWORK_SCHEMA,
|
||||
'ceph_monitor_nodes': NETWORK_METADATA,
|
||||
'ceph_primary_monitor_node': NETWORK_METADATA,
|
||||
'role': 'controller',
|
||||
})[0]
|
||||
first_node.connect(ceph_mon)
|
||||
first_node.connect(ceph_mon, {'ip': 'public_vip'})
|
||||
first_node.connect(ceph_mon, {'ip': 'management_vip'})
|
||||
library = vr.create('library1', 'resources/fuel_library', {})[0]
|
||||
first_node.connect(library)
|
||||
|
||||
# TODO(use library resource)
|
||||
# ceph_mon = vr.create('ceph_mon1', 'resources/ceph_mon',
|
||||
# {'storage': STORAGE,
|
||||
# 'keystone': KEYSTONE,
|
||||
# 'network_scheme': NETWORK_SCHEMA,
|
||||
# 'ceph_monitor_nodes': NETWORK_METADATA,
|
||||
# 'ceph_primary_monitor_node': NETWORK_METADATA,
|
||||
# 'role': 'controller',
|
||||
# })[0]
|
||||
# first_node.connect(ceph_mon,
|
||||
# {'ip': ['ip', 'public_vip', 'management_vip']})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,8 +1,6 @@
|
||||
id: ceph_mon
|
||||
handler: puppet
|
||||
version: 1.0.0
|
||||
|
||||
|
||||
input:
|
||||
library:
|
||||
schema: {repository: str!, branch: str!, puppet_modules: str}
|
||||
@ -39,5 +37,4 @@ input:
|
||||
role:
|
||||
schema: str!
|
||||
value:
|
||||
|
||||
tags: []
|
||||
|
20
resources/fuel_library/actions/run.sh
Normal file
20
resources/fuel_library/actions/run.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p {{temp_directory}}
|
||||
|
||||
pushd {{temp_directory}}
|
||||
if [ ! -d fuel-library ]
|
||||
then
|
||||
git clone -b {{ git['branch'] }} {{ git['repository'] }}
|
||||
else
|
||||
pushd ./fuel-library
|
||||
git pull
|
||||
popd
|
||||
fi
|
||||
pushd ./fuel-library/deployment
|
||||
./update_modules.sh
|
||||
popd
|
||||
|
||||
mkdir -p {{puppet_modules}}
|
||||
cp -r ./fuel-library/deployment/puppet/* {{puppet_modules}}
|
||||
popd
|
18
resources/fuel_library/meta.yaml
Normal file
18
resources/fuel_library/meta.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
id: fuel_library
|
||||
handler: shell
|
||||
version: 1.0.0
|
||||
input:
|
||||
ip:
|
||||
schema: str!
|
||||
value:
|
||||
git:
|
||||
schema: {repository: str!, branch: str!}
|
||||
value: {repository: 'https://github.com/stackforge/fuel-library',
|
||||
branch: 'stable/7.0'}
|
||||
temp_directory:
|
||||
schema: str!
|
||||
value: /tmp/solar
|
||||
puppet_modules:
|
||||
schema: str!
|
||||
value: /etc/fuel/modules
|
||||
tags: []
|
@ -133,7 +133,7 @@ class Puppet(TempFileHandler):
|
||||
|
||||
def upload_hiera_resource(self, resource):
|
||||
with open('/tmp/puppet_resource.yaml', 'w') as f:
|
||||
f.write(yaml.safe_dump(resource.args))
|
||||
f.write(yaml.safe_dump({resource.name: resource.args}))
|
||||
|
||||
self.transport_sync.copy(
|
||||
resource,
|
||||
@ -146,39 +146,9 @@ class Puppet(TempFileHandler):
|
||||
def upload_manifests(self, resource):
|
||||
if 'forge' in resource.args and resource.args['forge']:
|
||||
self.upload_manifests_forge(resource)
|
||||
elif 'library' in resource.args and resource.args['library']:
|
||||
self.upload_library(resource)
|
||||
else:
|
||||
self.upload_manifests_librarian(resource)
|
||||
|
||||
def upload_library(self, resource):
|
||||
git = resource.args['library']
|
||||
p = GitProvider(git['repository'], branch=git['branch'])
|
||||
|
||||
#fabric_ai.local('cd {}/deployment && ./update_modules.sh'.format(
|
||||
# p.directory))
|
||||
|
||||
fabric_api.local(
|
||||
'ansible-playbook -i "localhost," -c local /tmp/git-provider.yaml'
|
||||
)
|
||||
|
||||
modules_path = os.path.join(p.directory, git['puppet_modules'])
|
||||
|
||||
fuel_modules = '/etc/puppet/modules'
|
||||
self.transport_run.run(
|
||||
resource, 'sudo', 'mkdir', '-p', fuel_modules
|
||||
)
|
||||
|
||||
self.transport_sync.copy(resource, modules_path, '/tmp')
|
||||
self.transport_sync.sync_all()
|
||||
|
||||
self.transport_run.run(
|
||||
resource,
|
||||
'sudo', 'mv',
|
||||
'/tmp/{}/*'.format(os.path.split(modules_path)[1]),
|
||||
fuel_modules
|
||||
)
|
||||
|
||||
def upload_manifests_forge(self, resource):
|
||||
forge = resource.args['forge']
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user