1

I have a salt provisioner that is calling a shell script to compile Nginx with a few modules that are needed. This is the call to the script in the .sls:

nginx:
#  pkg.installed:
#    - name: nginx
  file.directory:
    - name: /src/
    - user: root
    - group: root
    - mode: 644
  cmd.run:
    - name: /srv/salt/config/nginx/compiler.sh | bash
    - cwd: /
    - require:
      - pkg: nginx-compiler-base

So it's /srv/salt/config/nginx/compiler.sh | bash that is run which does start. The script run is:

#!/bin/bash
cd ../../../../
cd /src/

nginxVersion="1.5.5" # set the value here from nginx website
wget http://nginx.org/download/nginx-$nginxVersion.tar.gz
tar -xzf nginx-$nginxVersion.tar.gz
#rm nginx # removes the soft link
ln -sf nginx-$nginxVersion nginx

cd nginx

    ./configure --with-http_auth_request_module \
    --with-http_gzip_static_module        \
    --with-http_stub_status_module        \
    --with-http_ssl_module                \
    --with-pcre                           \
    --with-file-aio                       \
    --with-http_realip_module             \
    --without-http_scgi_module            \
    --without-http_uwsgi_module           \
    --without-http_fastcgi_module

make
make install

Which does get to the untaring part. After which I get this as the output and failed message:

    enter image description here

If I ssh into the server, then su, I can run each line in the script and it works. I'm unsure why it's failing when the provisioner is failing.

1

so it seems that the cause was that I was using | bash when I was calling the script. In other words name: /srv/salt/config/nginx/compiler.sh | bash should have been name: /srv/salt/config/nginx/compiler.sh and so the salt .sls should have been:

# Set Nginx to run in levels 2345.
nginx:
  file.directory:
    - name: /src/
    - user: root
    - group: root
    - mode: 644
  cmd.run:
    - name: /srv/salt/config/nginx/compiler.sh
    - cwd: /
    - require:
      - pkg: nginx-compiler-base

and then the file, which I turned to:

#!/bin/bash
cd /src

nginxVersion="1.5.7" # set the value here from nginx website
wget -N http://nginx.org/download/nginx-$nginxVersion.tar.gz
tar -xzf nginx-$nginxVersion.tar.gz
ln -sf nginx-$nginxVersion nginx

cd /src/nginx

#mkdir /tmp/nginx-modules
#cd /tmp/nginx-modules
#wget https://github.com/agentzh/headers-more-nginx-module/archive/v0.19.tar.gz
#tar -xzvf v0.19.tar.gz 

./configure --with-http_auth_request_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-ipv6 --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module

#\
#--add-module=/tmp/nginx-modules/headers-more-nginx-module-0.19 \

make
make install

ran and it installed as hoped. Hope this saves someone some time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.