2

I have just started using Salt instead of Ansible. I am unsure whether to call the following script from the master or manually enter the commands into a salt state. For the latter can anyone suggest how to achieve this using cmd.run.

#!/bin/bash

. /lib/lsb/init-functions

cd /opt/concourse/bin/

./concourse worker \
  --name ci_worker01 \
  --bind-ip 0.0.0.0 \
  --bind-port 7777 \
  --work-dir /opt/concourse/worker \
  --tsa-host 127.0.0.1 \
  --tsa-port 2222 \
  --tsa-public-key /opt/concourse/.ssh/id_web_rsa.pub \
  --tsa-worker-private-key /opt/concourse/.ssh/id_worker_rsa &>/var/log/concourse/concourse_worker.log &
Adam Michalik
  • 9,678
  • 13
  • 71
  • 102
Atlantic0
  • 3,271
  • 5
  • 17
  • 24

1 Answers1

6

You could save your script to a file and call it using cmd.script state like this:

concourse_script:
  cmd.script:
    - name: salt://scripts/concourse.sh

Or you could use the same state to call the command and pass the args:

concourse_cmd:
  cmd.script:
    - name: ./concourse worker
    - cwd: /opt/concourse/bin/
    - args: "'--name ci_worker01' '--bind-ip 0.0.0.0' '--bind-port 7777' '--work-dir /opt/concourse/worker' '--tsa-host 127.0.0.1' '--tsa-port 2222' '--tsa-public-key /opt/concourse/.ssh/id_web_rsa.pub' '--tsa-public-key /opt/concourse/.ssh/id_web_rsa.pub'"

Mind that to pass a string containing spaces in YAML, you will need to doubly-quote it.

alejdg
  • 2,313
  • 21
  • 28