0

I am playing with SaltStack configured by org babel source blocks. I try to pass output of salt fingerprint to minion configuration file. If I use one command direcly in bash I receive this output:

# salt-key -f master.pub
Local Keys:
master.pub:  66:bf:a3:8f:f5:09:01:78:dc:d7:34:80:42:d0:ab:b6:f1:f6:67:ee:dd:80:10:d6:90:58:71:48:fa:d9:24:2c

When I try to execute the same command in org babel I receive different result (I attach screen because my browser doesn't support this symbol):

#+begin_src sh :session master
salt-key --finger=master.pub
#+end_src

org babel result

Because of this ^[ characters I receive wrong while extracting value of master.pub key which I need in further processing:

#+begin_src sh :session minion :var FINGERPRINT=fingerprint[1,1]
echo $FINGERPRINT
#+end_src

#+RESULTS:
|                                                                                                    |
| 66:bf:a3:8f:f5:09:01:78:dc:d7:34:80:42:d0:ab:b6:f1:f6:67:ee:dd:80:10:d6:90:58:71:48:fa:d9:24:2c;0m |

And because of the ";0m" at the end (I am not sure what it is) I can't copy and paste this value to configuration file. I tried different types of results (raw, table, list), but always I receive this characters. Anyone have idea how can I deal with this?

0

These are terminal escape codes to e.g. change colors and such. Usually, programs that do that have a --color=no or some similar option to turn this off. In fact, the salt-key manpage shows a --no-color option, so try adding that to the salt-key invocation.

  • Thank you! Now the output is fine! – AsterOps Sep 16 '20 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.