1

Using salt to provision and I want to be able to run cmd.script. The script works if i list all packages i intend to install within the script. But i will prefer to have the list of packages in salt formula and refer to it from the script. Below works ok.

salt-formula

Run masterscript:
  cmd.script:
    - name: masterscript
    - source: http://server/r-install.sh

r-install.sh

IFS=","
packages="'devtools','shiny','rmarkdown','plyr','shinydashboard','googleVis','RPostgreSQL','reshape2','xtable','DT','lattice','latticeExtra','ggplot2','formattable','plotly','htmlwidgets','shinyBS','stringr','DBI'"
for i in $packages; do su - -c "R -e \"install.packages($i, repos='http://cran.rstudio.com')\""; done

I will prefer to list the packages in pillar ie:

r:
  packages:
     - package1
     - package2

1 Answer 1

1

salt-formula:

Run masterscript:
  cmd.script:
    - name: masterscript
    - source: http://server/r-install.sh
    - template: jinja

r-install.sh:

{%- for package in salt['pillar.get']('r:packages', []) %}
su - -c "R -e \"install.packages({{package}}, repos='http://cran.rstudio.com')\""
{% endfor -%}
1
  • Thanks @david Houde. Was away. Tested and works fine. Brilliant May 21, 2017 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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