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
chicks
  • 3,639
  • 10
  • 26
  • 36

1 Answers1

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 -%}
David Houde
  • 3,160
  • 1
  • 15
  • 19