Comments (5)
This is a bug, I'll handle an update shortly.
from marionette.
I did install from master, saw the new version come in, and it doesn't fly:
shell { name => "Adding datadir, adding new",
command => ["sed -i \'s/user/#user/g\' ${HOME}/.my.cnf"],
}
sed: -e expression #1, char 18: unterminated address regex
Error:error running shell-module rule 'Adding datadir, adding new' error running command 'sed -i \'s/user/#user/g\' /home/ps893826/.my.cnf' exit status 1
from marionette.
Looking at this more carefully I think there's some confusion.
This is my sample input:
shell {
command => "echo \"user is bob\" > test.conf",
}
shell {
command => ["sed -i s/user/#user/g test.conf"],
}
- The first block writes to test.conf
user is bob
- The second block runs sed
- Replacing
user
with#user
- Replacing
That works 100%. No quoting involved.
Adding quotes around the sed-input causes failure:
command => "sed -i 's/user/#user/g' test.conf",
command => "sed -i \"s/user/#user/g\" test.conf",
In both cases the error is from sed, which looks like this:
- sed: -e expression #1, char 1: unknown command: `''
- sed: -e expression #1, char 1: unknown command: `"'
i.e. The issue here is that the command is being taken with the quotes literally, because we're not runnign with a shell.
So I think the immediate problem you have is solved by dropping the quotes.
The second problem is caused by not running with bash. I think that can be solved by adding a needless redirect:
shell {
command => ["sed -i \"s/user/#user/g\" test.conf >/dev/null"],
}
That's because the way that I run shell commands depends on whether there is a redirection, or similar "complex" thing present.
I hope that one/other of those solves things for you. But I guess I'll leave this open and see if I can add:
shell => "true"
To force the use of the shell, rather than the hack with the redirection character.
from marionette.
OK I see it work as you say, and this is nice I don't want to deal with escaping.
Thank you, I am enjoying marionette, I see it filling a lane that is quite missing out there. I am using it to provision a development environment. Some additions that would be good
- a --version flag
- a mysql module, where I can execute sql. Right now I am shelling out, but that defeats the purpose
- A find and replacer, like I am doing with sed, the file module seems close but I need more fine grained control.
command => "sed -i 's/user/#user/g' ${HOME}/.my.cnf > /dev/null",
from marionette.
Good comments. I'll create issues for the missing features you suggest.
For editing I've done a hack which is to use the edit-module twice;
- Once to remove lines matching a pattern.
- Once to add the intended thing.
Doesn't work generally, such as changing the port of sshd, but it can work in emergencies.
I can see this working, and being easy to add:
edit {
target => "path/to/file",
search => "old",
replace => "new",
}
from marionette.
Related Issues (20)
- contains doesn't work on cat'd file HOT 3
- Create file if not exists? HOT 3
- Add --version flag
- Allow search & replace inside existing files
- Add parameter to shell-module to force the use of a shell
- Add mysql module HOT 3
- Consider types - integers and booleans at least HOT 2
- directory module doesn't -p HOT 5
- Allow modules to setup output variables HOT 1
- Allow function-calls ..
- Package installation order HOT 1
- Update the module API
- Negative numbers aren't parsed
- broke lately HOT 7
- how do I install a specific version? HOT 2
- missing artifact for arch arm64
- add the ability to use sudo/doas when installing package, modifying user/group,... HOT 3
- no output from package module
- marionette calling help
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marionette.