Ansible Version: 2.1.2.0
So I have a yaml file with a multi line variable that's from a binary file converted to base 64.
My variable file: self-cert.yml
selfcert: |
MIIKCAIBAzCCCcIGCSqGSIb3DQEHAaCCCbMEggmvMIIJqzCCBWgGCSqGSIb3DQEHAaCCBVkEggVV
MIIFUTCCBU0GCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQFa98IY7UgblDK
qGwMjTIQCK+3DwICBAAEggTIvA/VFm3j3oSN6cknp5qFyUxXAI5TxURnyx8UVRm8UfMcA0LHlh+z
06ztcwApIrxMSV26ezu0p1FrHInpbABNuO0rlk4XlQwTkLynUyg58iBwK7IyV5SqT2UC8djaOiMN
b9ViC3yn7SrRdS3MmCQznu6dScRIHbhG46yZNJrzrJh038X2KAPpS/LfC9DJBjaEzkZY8BwyARYe
When I try to run my playbook that includes this variable, I get:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/home/ansible/projects/install-cert/self-cert.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
MIIKCAIBAzCCCcIGCSqGSIb3DQEHAaCCCbMEggmvMIIJqzCCBWgGCSqGSIb3DQEHAaCCBVkEggVV
MIIFUTCCBU0GCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQFa98IY7UgblDK
^ here
Any idea whats wrong? I've tried changing | to > , didn't work, and i've also tried indenting the whole base64 output too.
So it turns out you do need to make an indentation to the the multiline variable. My original indentation was an actual tab instead of spaces (Stupid Sublime) and so the indentation failed the syntax check, but using actual spaces made everything work.
Related
I'm trying to run a python script using Sublime Text 3. I'm trying to just use Ctrl+b and type the parameters in the box that comes up, but I can't for the life of me figure out how to format the Windows file paths. I keep getting a FileNotFoundError
I've tried:
"C:\dir1\dir 2\file.ext"
"C:\\dir1\\dir 2\\file.ext"
"C:/dir1/dir 2/file.ext"
Because some of my directories have spaces in them, I'm enclosing the whole thing in double quotes no matter which slash style I try. What am I missing here? None of these works.
With the first, for example, I'm getting FileNotFoundError: [Errno 2] No such file or directory: 'C:\\dir1\\dir 2\\file.ext,' [Finished in 0.3s]
The file is most definitely there and spelled correctly.
In case it matters, I'm using docopt to parse the input parameters
I keep getting a syntax error against the "C" in "C:\Users".
`#! python3
print('Hello world')`
#C:\Users\AK\MyPythonScripts>py.exe hello.bat
# File "hello.bat", line 1
# #py C:\User\AK\MyPythonSctipts\hello.py %*
# ^
#SyntaxError: invalid syntax
I've tried adding "\". I can't figure it out. Following along in "Automate the Boring Stuff." (Lesson 22)
#I keep getting a syntax error against the "C" in "C:\Users".
`#! python3
print('Hello world')`
#C:\Users\AK\MyPythonScripts>py.exe hello.bat
# File "hello.bat", line 1
# #py C:\User\AK\MyPythonSctipts\hello.py %*
# ^
#SyntaxError: invalid syntax
I expect to run the batch file and added a "#pause" feature, but the program won't execute since "C" is an invalid syntax.
May not the perfect answer you are looking for, but let me share in general essense how you run a python script in windows.
Open Command line: Start menu -> Run and type cmd
Type: C:\python27\python.exe C:\Users\Awesome\Desktop\Adel.py
In your system, your python .exe location might a bit different or you could be using python3, but overall format is specify you python exe first followed by your script's full path (<python.exe> <python-script-full-path>
I figured it out! My command prompt path wasn't set properly. I went to "My Computer" -> right-click -> Properties -> Advanced System Settings and changed my environment variable.
I am using a custom config of collectd and for some reason I keep getting a failure when I try and run the service. Originally I had everything in one big file, but to make changing configs easier I want to separate out the settings for various plugins and components. Collectd has a Include option to do exactly this. It seems to work, but when collectd tries to grab the external part of the program I get the following error:
Parse error in file `/etc/collectd/collectd.conf.d/http.conf', line 1100 near `': syntax error, unexpected $end, expecting EOL
If I go in and copy paste direct into the server using vim, it will work. However when the package installs it won't. I know these kinds of errors can come from mismatched brackets or quotes or something, but his is not a problem in these files. Is there anything else which could cause such an error?
For the users they have similar error at you. For my case, i have not return line at the bottom of collectd.conf or plugins configuration files. For verify, you can use this command
$ xxd collectd.conf | tail -n1 | grep 0a
00001c0: 730a 0a s..
You must see the 0a at the end of the file
Note : You can replace collectd.conf by plugins configuration files
Following the technique here, I got the vbc command line used to compile my project. I've used this to compile the project from the command line and it's worked fine the several times I've tried it. The command line is about 25,000 characters long, if that means anything.
But today when I ran the command, I got a bunch of errors that look like this:
vbc : Command line error BC2001 : file 'admin\TestShare.aspxvb' could not be found
However, when I look at the actual command line for the reference to that file, it's correct:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Vbc.exe ... admin\TestShare.aspx.vb ...
All of the other "file could not be found" errors are similar: it's dropping characters from the filename (not just dots but text characters as well), and then it says it can't find that file.
What's going on here?
Update: That first bad file is right near character 8192 in the command line, which suggests that the problem is related to the path being too long for Windows. But if this is the problem, how can I build my app from the command line?
If you just need to build from the command line, why not use msbuild instead? All that is necessary is a msbuild YourProject.proj to get things rolling, and much shorter than the verbose way ;-) Run from VS command prompt.
First, I run
/bin/bash a.sh
It succeed.
But when I want to run
/bin/bash a.sh > a_info.txt
It failed.
Error: line 1: !#/bin/bash: No such file or directory
It does not seem that it’s '^M' that’s causing this error.
The shebang pattern is #!/bin/your_shell, not !#/bin/your_shell. Just fix the typo.
Check the file's encoding.
If you get this error, but you did not misspell the 'shebang', have a close look at the file's encoding. I was getting this error on a file with encoding 'UTF8 with BOM'... I guess the BOM (Byte Order Mark) was causing the problem. Changed the encoding to ASCII and that fixed it (or you can use 'UTF-8 without BOM' which is effectively the same for files only containing ASCII characters).
Another possible cause of the "No such file or directory" error is if your shell script is using CRLF instead of LF line endings.