-
- task "prod-task2-sync" {
- # The "raw_exec" parameter specifies the task driver that should be used
- # to run the task.
- driver = "raw_exec"
-
- # The "template" stanza instructs Nomad to manage a template, such as
- # a configuration file or script. This template can optionally pull data
- # from Consul or Vault to populate runtime configuration data.
- #
- # For more information and examples on the "template" stanza, please see
- # the online documentation at:
- #
- # https://www.nomadproject.io/docs/job-specification/template.html
- #
- template {
- data = <<EOH
-#!/bin/bash
-
-INOTIFY_OPTONS="--recursive --monitor"
-VOLUMES="/data/logs.fd.io /data/docs.fd.io"
-
-if [ '{{ env "attr.unique.network.ip-address" }}' = "10.32.8.14" ]; then
-echo "Running notify daemon"
- inotifywait -e moved_to ${INOTIFY_OPTONS} ${VOLUMES} | \
- while read path action file; do
- key="testuser"
- secret="Csit1234"
-
- resource=${path#"/data"}${file}
- date=$(date -R)
- _signature="PUT\n\napplication/octet-stream\n${date}\n${resource}"
- signature=$(echo -en ${_signature} | openssl sha1 -hmac ${secret} -binary | base64)
-
- curl -v -X PUT -T "${path}${file}" \
- -H "Host: storage0.storage.service.consul:9000" \
- -H "Date: ${date}" \
- -H "Content-Type: application/octet-stream" \
- -H "Authorization: AWS ${key}:${signature}" \
- http://storage0.storage.service.consul:9000${resource}
- done
-else
- while :; do sleep 2073600; done
-fi
-
-EOH
- destination = "local/sync.sh"
- perms = "755"
- }
-
- # The "config" stanza specifies the driver configuration, which is passed
- # directly to the driver to start the task. The details of configurations
- # are specific to each driver, so please see specific driver
- # documentation for more information.
- config {
- command = "local/sync.sh"
- }
-
- # The "resources" stanza describes the requirements a task needs to
- # execute. Resource requirements include memory, network, cpu, and more.
- # This ensures the task will execute on a machine that contains enough
- # resource capacity.
- #
- # For more information and examples on the "resources" stanza, please see
- # the online documentation at:
- #
- # https://www.nomadproject.io/docs/job-specification/resources.html
- #
- resources {
- cpu = 500
- memory = 256
- }
- }