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), ('from', 'f2s/resources/'+RoleData.name),
('location', "{{node}}"), ('location', "{{node}}"),
('values', {'uid': '{{index}}', ('values', {'uid': '{{index}}',
'env': '{{env}}'})]) 'env': '{{env}}',
'puppet_modules': '/etc/puppet/modules'})])
for t, _, _ in self.tasks: for t, _, _ in self.tasks:
if t.name in self.filtered: 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] return [(uid, ip_mask % uid, 1) for uid in uids]
def roles(self, uid): def roles(self, uid):
return 'primary-controller' return ['primary-controller']
def master(self): def master(self):
return 'master', '0.0.0.0' return 'master', '0.0.0.0'
@ -72,7 +72,7 @@ def prep(uids):
def roles(uids): def roles(uids):
for uid, ip, env in source.nodes(uids): for uid, ip, env in source.nodes(uids):
role = source.roles(uid) for role in source.roles(uid):
vr.create(role, 'f2s/vrs/'+role +'.yml', vr.create(role, 'f2s/vrs/'+role +'.yml',
{'index': uid, 'env': env, 'node': 'node'+uid}) {'index': uid, 'env': env, 'node': 'node'+uid})

View File

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

View File

@ -30,13 +30,15 @@ def prepare_hiera():
with open('/etc/puppet/hiera.yaml', 'w') as f: with open('/etc/puppet/hiera.yaml', 'w') as f:
f.write(hiera_conf) 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: 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(): def run_command():
cmd = [ 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')] os.path.join(CURDIR, 'globals.pp')]
return execute(cmd) return execute(cmd)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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