salt icon indicating copy to clipboard operation
salt copied to clipboard

pillar vs. --pillar command line options triggers test mode when using special pillar values

Open RobertFach opened this issue 11 years ago • 3 comments

I have a strange issue with a tool (vagrant) that sets pillars with the pillar='' command line option. I wanted to pass in an ssh-key as pillar data using the command line. The key consists of '\n' characters which seem to cause the state.highstate running in test=True mode. Setting test=False results in a message that test has been already set. State changes are in "yellow" and won't be applied.

Running the same command line just with --pillar='' and the same pillar data is executing the highstate but doesn't set the pillar data at all

vagrant@XXX-dev-vm-e1e89d6918c2c2e1:~$ salt-call --version salt-call 2014.7.0 (Helium)

sudo salt-call state.highstate pillar='{"test":"\n"}' is somehow resulting in test=True

sudo salt-call state.highstate pillar='{"test":""}' or sudo salt-call state.highstate --pillar='{"test":"\n"}'

I'm confused, according to the documentation, "pillar" and not "--pillar" should be the correct option to go.

RobertFach avatar Jan 19 '15 14:01 RobertFach

Just to keep you updated... I'm currently tracking down this issue... It looks as the pillar option doesn't get recognized when it contains a newline character...

Therefore I made a test in salt/cli/caller.py (ZeroMQCaller).

ZMQ Caller when called with pillar data without new line character... [] {'__pub_fun': 'state.highstate', 'pillar': {'test': 'a'}, '__pub_pid': 11910, '__pub_jid': '20150122182846794342', '__pub_tgt': 'salt-call'}

ZMQ Caller when called with pillar data containing newline characters ['pillar={"test":"\na"}'] {'__pub_fun': 'state.highstate', '__pub_jid': '20150122182910605553', '__pub_pid': 11963, '__pub_tgt': 'salt-call'}

... Digging deeper it looks like

salt.utils.args.parse_input(self.opts['arg']) ['pillar={"xxx":"\na"}']

doesn't translate the arguments correctly.

salt.utils.args.parse_input(self.opts['arg']) [{'pillar': {'xxx': 'a'}, 'kwarg': True}]

... and deeper in utils/args.py we can find the regex that matches kwargs

KWARG_REGEX = re.compile(r'^([^\d\W][\w.-])=(?!=)(.)$')

and that expression doesn't match multiline... Therefore, I think the multiline pillar issue should be fixed by extending the regex. However, it's not yet clear why the test mode gets enabled. Maybe this is somehow triggered because of the pillar data which gets passed in as argument and not kw argument (if its a multiline argument).

Any comments/ideas @pitatus and @rallytime

Cheers,

RobertFach avatar Jan 22 '15 18:01 RobertFach

Thanks for including the additional info.. sorry don't have a suggestion but it needs to be looked at..

pitatus avatar Jan 26 '15 20:01 pitatus

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Nov 10 '17 17:11 stale[bot]