Giter VIP home page Giter VIP logo

Comments (5)

skx avatar skx commented on May 27, 2024

This is a bug, I'll handle an update shortly.

from marionette.

httpete avatar httpete commented on May 27, 2024

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.

skx avatar skx commented on May 27, 2024

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

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.

httpete avatar httpete commented on May 27, 2024

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

  1. a --version flag
  2. a mysql module, where I can execute sql. Right now I am shelling out, but that defeats the purpose
  3. 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.

skx avatar skx commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.