Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudo option with one line script #139

Closed
shikhov opened this issue Jul 18, 2023 · 2 comments
Closed

Sudo option with one line script #139

shikhov opened this issue Jul 18, 2023 · 2 comments

Comments

@shikhov
Copy link

shikhov commented Jul 18, 2023

Playbook:

tasks:
  - name: test
    commands:
      - name: echo-test
        script: echo $appname

Without sudo option script works fine:

 run task "test", commands: 1
  > sh -c 'appname="myapp"; echo $appname'
  > myapp
 completed command "echo-test" {script: sh -c 'appname="myapp"; echo $appname'} (244ms)
 completed task "test", commands: 1 (770ms)

With sudo option variable $appname is empty:

 run task "test", commands: 1
  > sudo sh -c "sh -c 'appname=\"myapp\"; echo $appname'"
  > 
 completed command "echo-test" {script: sh -c 'appname="myapp"; echo $appname', sudo: true} (255ms)
 completed task "test", commands: 1 (769ms)
@knutov
Copy link
Contributor

knutov commented Jul 18, 2023

it's because echo is built-in command. Use /bin/echo for this

@umputun
Copy link
Owner

umputun commented Jul 18, 2023

pls check 1.9.2, it should be working for your case now

@shikhov shikhov closed this as completed Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants