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

cmd.run/cmd.script getting TypeError: coercing to Unicode: need string or buffer, bool found #12400

Closed
feiming opened this issue Apr 30, 2014 · 6 comments

Comments

@feiming
Copy link

@feiming feiming commented Apr 30, 2014

I had tried with cmd.run and cmd.script. Both gave the same error as below.

This is the error message:

[root@experiment moosefs]# salt-call --local state.highstate -l debug
...
...
...
          ID: salt://moosefs/files/install_script.sh
    Function: cmd.script
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.6/site-packages/salt/state.py", line 1371, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.6/site-packages/salt/states/cmd.py", line 749, in script
                  cmd_all = __salt__['cmd.script'](source, **cmd_kwargs)
                File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 995, in script
                  saltenv=saltenv)
                File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 261, in _run
                  if not os.path.isfile(shell) or not os.access(shell, os.X_OK):
                File "/usr/lib64/python2.6/genericpath.py", line 29, in isfile
                  st = os.stat(path)
              TypeError: coercing to Unicode: need string or buffer, bool found
     Changes:   

I'm running a masterless Salt. This is the state file and other related info:

[root@experiment moosefs]# cat master.sls 
{% from "moosefs/map.jinja" import moosefs with context %}

include:
  - moosefs

salt://moosefs/files/install_script.sh:
  cmd.script:
    - cwd: /tmp
    - user: root
    - shell: True
[root@experiment moosefs]# cat files/install_script.sh 
#!/bin/bash

cd /tmp
wget -c http://moosefs.org/tl_files/mfscode/mfs-1.6.27-5.tar.gz
tar xzvf mfs-1.6.27-5.tar.gz
cd mfs-1.6.27
./configure --prefix=/usr --sysconfdir=/etc/moosefs --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
make
make install
[root@experiment moosefs]# salt-minion --version
salt-minion 2014.1.0
[root@experiment moosefs]# uname -a
Linux experiment 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

@feiming

This comment has been minimized.

Copy link
Author

@feiming feiming commented Apr 30, 2014

cmd.run error message:

          ID: Install_Master
    Function: cmd.run
        Name: cd /tmp
wget -c http://moosefs.org/tl_files/mfscode/mfs-1.6.27-5.tar.gz -O mfs.tar.gz
tar -xzvf mfs.tar.gz
cd mfs-1.6.27
./configure --prefix=/usr --sysconfdir=/etc/moosefs --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
make
make install

      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.6/site-packages/salt/state.py", line 1371, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.6/site-packages/salt/states/cmd.py", line 589, in run
                  name, timeout=timeout, **cmd_kwargs
                File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 803, in run_all
                  saltenv=saltenv)
                File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 261, in _run
                  if not os.path.isfile(shell) or not os.access(shell, os.X_OK):
                File "/usr/lib64/python2.6/genericpath.py", line 29, in isfile
                  st = os.stat(path)
              TypeError: coercing to Unicode: need string or buffer, bool found
     Changes:   

state file:

include:
  - moosefs

Install_Master:
  cmd.run:
    - name: |
        cd /tmp
        wget -c {{ fs_pkg_url }} -O mfs.tar.gz
        tar -xzvf mfs.tar.gz
        cd {{ fs_folder }}
        ./configure --prefix=/usr --sysconfdir=/etc/moosefs --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
        make
        make install
    - cwd: /tmp
    - shell: true
    - timeout: 300
@feiming

This comment has been minimized.

Copy link
Author

@feiming feiming commented Apr 30, 2014

Replicated this error on another Centos box

[INFO    ] Running state [cd /tmp
wget -c http://moosefs.org/tl_files/mfscode/mfs-1.6.27-5.tar.gz -O mfs.tar.gz
tar -xzvf mfs.tar.gz
cd mfs-1.6.27
./configure --prefix=/usr --sysconfdir=/etc/moosefs --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
make
make install
] at time 01:40:19.335165
[INFO    ] Executing state cmd.run for cd /tmp
wget -c http://moosefs.org/tl_files/mfscode/mfs-1.6.27-5.tar.gz -O mfs.tar.gz
tar -xzvf mfs.tar.gz
cd mfs-1.6.27
./configure --prefix=/usr --sysconfdir=/etc/moosefs --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
make
make install

[ERROR   ] An exception occurred in this state: Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/state.py", line 1371, in call
    **cdata['kwargs'])
  File "/usr/lib/python2.6/site-packages/salt/states/cmd.py", line 589, in run
    name, timeout=timeout, **cmd_kwargs
  File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 803, in run_all
    saltenv=saltenv)
  File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 261, in _run
    if not os.path.isfile(shell) or not os.access(shell, os.X_OK):
  File "/usr/lib/python2.6/genericpath.py", line 29, in isfile
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, bool found

@s0undt3ch

This comment has been minimized.

Copy link
Member

@s0undt3ch s0undt3ch commented Apr 30, 2014

I know salt could explain better what happened but the trace actually tells us the issue.

Shell is meant to select a different shell to use, not to say that you want to use a shell.

Pedro Algarvio @ Phone

----- Reply message -----
From: "Fabian Chong" notifications@github.com
To: "saltstack/salt" salt@noreply.github.com
Subject: [salt] cmd.run/cmd.script getting TypeError: coercing to Unicode: need string or buffer, bool found (#12400)
Date: Wed, Apr 30, 2014 07:06
I had tried with cmd.run and cmd.script. Both gave the same error as below.

This is the error message:

[root@experiment moosefs]# salt-call --local state.highstate -l debug
...
...
...
ID: salt://moosefs/files/install_script.sh
Function: cmd.script
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/state.py", line 1371, in call
**cdata['kwargs'])
File "/usr/lib/python2.6/site-packages/salt/states/cmd.py", line 749, in script
cmd_all = salt['cmd.script'](source, **cmd_kwargs)
File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 995, in script
saltenv=saltenv)
File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 261, in _run
if not os.path.isfile(shell) or not os.access(shell, os.X_OK):
File "/usr/lib64/python2.6/genericpath.py", line 29, in isfile
st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, bool found
Changes:

I'm running a masterless Salt. This is the state file and other related info:

[root@experiment moosefs]# cat master.sls
{% from "moosefs/map.jinja" import moosefs with context %}

include:

  • moosefs

salt://moosefs/files/install_script.sh:
cmd.script:

  • cwd: /tmp
  • user: root
  • shell: True

[root@experiment moosefs]# cat files/install_script.sh
#!/bin/bash

cd /tmp
wget -c http://moosefs.org/tl_files/mfscode/mfs-1.6.27-5.tar.gz
tar xzvf mfs-1.6.27-5.tar.gz
cd mfs-1.6.27
./configure --prefix=/usr --sysconfdir=/etc/moosefs --localstatedir=/var/lib --with-default-user=mfs --with-default-group=mfs --disable-mfschunkserver --disable-mfsmount
make
make install

[root@experiment moosefs]# salt-minion --version
salt-minion 2014.1.0
[root@experiment moosefs]# uname -a
Linux experiment 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


Reply to this email directly or view it on GitHub.

@feiming

This comment has been minimized.

Copy link
Author

@feiming feiming commented Apr 30, 2014

thanks. i followed the wrong tutorial

@feiming feiming closed this Apr 30, 2014
@s0undt3ch

This comment has been minimized.

Copy link
Member

@s0undt3ch s0undt3ch commented Apr 30, 2014

Can you paste a link to such tutorial? If its ours we need to fix it.

Pedro Algarvio @ Phone

----- Reply message -----
From: "Fabian Chong" notifications@github.com
To: "saltstack/salt" salt@noreply.github.com
Cc: "Pedro Algarvio" pedro@algarvio.me
Subject: [salt] cmd.run/cmd.script getting TypeError: coercing to Unicode: need string or buffer, bool found (#12400)
Date: Wed, Apr 30, 2014 09:51
thanks. i followed the wrong tutorial


Reply to this email directly or view it on GitHub.

@notpeter

This comment has been minimized.

Copy link
Contributor

@notpeter notpeter commented Sep 9, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.