Fix tasks, ssh config and prefetching information from nailgun

This commit is contained in:
Dmitry Shulyak 2015-11-12 17:13:08 +02:00
parent 9d8415ba19
commit c6416517ca
11 changed files with 33 additions and 33 deletions

View File

@ -170,7 +170,8 @@ class DGroup(object):
('from', 'f2s/resources/'+RoleData.name),
('location', "{{node}}"),
('values', {'uid': '{{index}}',
'env': '{{env}}'})])
'env': '{{env}}',
'puppet_modules': '/etc/puppet/modules'})])
for t, _, _ in self.tasks:
if t.name in self.filtered:

View File

@ -34,7 +34,7 @@ class DumbSource(object):
return [(uid, ip_mask % uid, 1) for uid in uids]
def roles(self, uid):
return 'primary-controller'
return ['primary-controller']
def master(self):
return 'master', '0.0.0.0'
@ -72,9 +72,9 @@ def prep(uids):
def roles(uids):
for uid, ip, env in source.nodes(uids):
role = source.roles(uid)
vr.create(role, 'f2s/vrs/'+role +'.yml',
{'index': uid, 'env': env, 'node': 'node'+uid})
for role in source.roles(uid):
vr.create(role, 'f2s/vrs/'+role +'.yml',
{'index': uid, 'env': env, 'node': 'node'+uid})
if __name__ == '__main__':

View File

@ -1,8 +1,8 @@
#!/bin/sh
cluster_id={{uid}}
open_ssl_keys={{ssl|join(' ')}}
ssh_keys={{ ssh|join(' ') }}
open_ssl_keys='{{ssl|join(' ')}}'
ssh_keys='{{ ssh|join(' ') }}'
keys_path={{path}}
BASE_PATH=$keys_path/$cluster_id/

View File

@ -30,13 +30,15 @@ def prepare_hiera():
with open('/etc/puppet/hiera.yaml', 'w') as f:
f.write(hiera_conf)
# dont dump null values
sanitized = {key:ARGS[key] for key in ARGS if ARGS.get(key)}
with open('/etc/puppet/hieradata/{}.yaml'.format(ARGS['uid']), 'w') as f:
f.write(yaml.safe_dump(ARGS))
f.write(yaml.safe_dump(sanitized))
def run_command():
cmd = [
'puppet', 'apply', '--modulepath={}'.format(ARGS['puppet_modules']),
'puppet', 'apply', '--hiera_config=/etc/puppet/hiera.yaml',
'--modulepath={}'.format(ARGS['puppet_modules']),
os.path.join(CURDIR, 'globals.pp')]
return execute(cmd)

View File

@ -6,7 +6,6 @@ managers:
- managers/from_nailgun.py
- managers/globals.py
input:
# should be auto-generated based on outputs from globals.pp
puppet_modules:
type: str!
value: /etc/puppet/modules
@ -16,6 +15,10 @@ input:
env:
type: str!
value:
tasks:
value:
ironic:
value:
access:
value: null
access_hash:

View File

@ -6,6 +6,7 @@ resources:
values:
env: '{{env}}'
uid: '{{index}}'
puppet_modules: '/etc/puppet/modules'
- id: fuel_pkgs{{index}}
from: f2s/resources/fuel_pkgs
location: '{{node}}'

View File

@ -6,6 +6,7 @@ resources:
values:
env: '{{env}}'
uid: '{{index}}'
puppet_modules: '/etc/puppet/modules'
- id: fuel_pkgs{{index}}
from: f2s/resources/fuel_pkgs
location: '{{node}}'

View File

@ -1,11 +1,10 @@
id: fuel_node
resources:
{% for i in range(1|int) %}
- id: ssh_transport{{index}}
from: resources/transport_ssh
values:
ssh_user: 'root'
ssh_key: '/root/.ssh/id_rsa'
ssh_key: '/root/.ssh/bootstrap.rsa'
- id: transports{{index}}
from: resources/transports
values:
@ -19,4 +18,3 @@ resources:
name: node{{index}}
ip: {{ip}}
transports_id: transports{{index}}::transports_id
{% endfor %}

View File

@ -5,22 +5,16 @@ resources:
location: {{node}}
values:
sources:
- src: /var/lib/fuel/keys/{{env}}/neutron/neutron.pub
dst: /var/lib/astute/neutron/neutron.pub
- src: /var/lib/fuel/keys/{{env}}/neutron/neutron
dst: /var/lib/astute/neutron/neutron
- src: /var/lib/fuel/keys/{{env}}/nova/nova.pub
dst: /var/lib/astute/nova/nova.pub
- src: /var/lib/fuel/keys/{{env}}/nova/nova
dst: /var/lib/astute/nova/nova
- src: /var/lib/fuel/keys/{{env}}/mysql/mysql.pub
dst: /var/lib/astute/mysql/mysql.pub
- src: /var/lib/fuel/keys/{{env}}/mysql/mysql
dst: /var/lib/astute/mysql/mysql
- src: /var/lib/fuel/keys/{{env}}/mongodb/mongodb.key
dst: /var/lib/astute/mongodb/mongodb.key
- src: /var/lib/fuel/keys/{{env}}/neutron
dst: /var/lib/astute
- src: /var/lib/fuel/keys/{{env}}/nova
dst: /var/lib/astute
- src: /var/lib/fuel/keys/{{env}}/mysql
dst: /var/lib/astute
- src: /var/lib/fuel/keys/{{env}}/mongo
dst: /var/lib/astute
- src: /etc/puppet/modules
dst: /etc/puppet/modules
dst: /etc/puppet/
- id: mos_repos{{index}}
from: templates/mos_repos.yaml
values:

View File

@ -6,6 +6,7 @@ resources:
values:
env: '{{env}}'
uid: '{{index}}'
puppet_modules: '/etc/puppet/modules'
- id: fuel_pkgs{{index}}
from: f2s/resources/fuel_pkgs
location: '{{node}}'

View File

@ -290,12 +290,11 @@ class Resource(object):
if not self.db_obj.managers:
return
manager_stack = self.db_obj.managers
while manager_stack:
manager = manager_stack.pop(0)
for manager in self.db_obj.managers:
manager_path = os.path.join(self.db_obj.base_path, manager)
rst = utils.communicate([manager_path], json.dumps(self.args))
self.update(json.loads(rst))
if rst:
self.update(json.loads(rst))
def load(name):
r = DBResource.get(name)