mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Build pillar data while allowing extra pillar key/values
This commit is contained in:
parent
d58000c7a8
commit
26570d5efc
1 changed files with 20 additions and 10 deletions
|
@ -43,6 +43,7 @@ except ImportError:
|
|||
from nb_popen import NonBlockingPopen
|
||||
|
||||
# Import 3rd-party libs
|
||||
import yaml
|
||||
try:
|
||||
import github
|
||||
HAS_GITHUB = True
|
||||
|
@ -52,6 +53,19 @@ except ImportError:
|
|||
SALT_GIT_URL = 'https://github.com/saltstack/salt.git'
|
||||
|
||||
|
||||
def build_pillar_data(options):
|
||||
'''
|
||||
Build a YAML formatted string to properly pass pillar data
|
||||
'''
|
||||
pillar = {
|
||||
'git_commit': options.commit,
|
||||
'salt_url': options.salt_url,
|
||||
}
|
||||
if options.pillar:
|
||||
pillar.update(dict(options.pillar))
|
||||
return yaml.dump(pillar).rstrip()
|
||||
|
||||
|
||||
def generate_vm_name(platform):
|
||||
'''
|
||||
Generate a random enough vm name
|
||||
|
@ -359,10 +373,7 @@ def run(opts):
|
|||
'salt -t 1800 {vm_name} state.sls {prep_sls} pillar="{pillar}" '
|
||||
'--no-color'.format(
|
||||
prep_sls=opts.prep_sls,
|
||||
pillar=opts.pillar.format(
|
||||
commit=opts.commit,
|
||||
salt_url=opts.salt_url
|
||||
),
|
||||
pillar=build_pillar_data(opts),
|
||||
vm_name=vm_name,
|
||||
commit=opts.commit
|
||||
)
|
||||
|
@ -475,10 +486,7 @@ def run(opts):
|
|||
'salt -t 1800 {vm_name} state.sls {sls} pillar="{pillar}" '
|
||||
'--no-color'.format(
|
||||
sls=opts.sls,
|
||||
pillar=opts.pillar.format(
|
||||
commit=opts.commit,
|
||||
salt_url=opts.salt_url
|
||||
),
|
||||
pillar=build_pillar_data(opts),
|
||||
vm_name=vm_name,
|
||||
commit=opts.commit
|
||||
)
|
||||
|
@ -565,8 +573,10 @@ def parse():
|
|||
help='The final sls file to execute')
|
||||
parser.add_option(
|
||||
'--pillar',
|
||||
default='{{git_commit: {commit}, git_url: \'{salt_url}\'}}',
|
||||
help='Pillar values to pass to the sls file')
|
||||
action='append',
|
||||
nargs=2,
|
||||
help='Pillar (key, value)s to pass to the sls file. '
|
||||
'Example: \'--pillar pillar_key pillar_value\'')
|
||||
parser.add_option(
|
||||
'--no-clean',
|
||||
dest='clean',
|
||||
|
|
Loading…
Add table
Reference in a new issue