Last active
August 29, 2015 14:22
-
-
Save rafi/f55c47040f5dc88c54ad to your computer and use it in GitHub Desktop.
Converting Circus celery worker ini files into Ansible yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "workers:" | |
find roles/ -iname 'celery*' | xargs grep -h 'watcher\|cmd' \ | |
| gsed "s/'/\"/g" \ | |
| gsed "s/\s*{{ ansible_nodename }}//g" \ | |
| gsed 's/--time-limit=//' \ | |
| gsed 's/\-[OQlnc]\s\+//g' \ | |
| awk -F'"' '{for(i=2;i<=NF;i++)if(i%2==0)gsub(" ","_",$i);}1' OFS="\"" \ | |
| gsed "s/{{\s/{{_/g" \ | |
| gsed "s/\s}}/_}}/g" \ | |
| awk ' | |
/^\[watcher/ { | |
gsub(/^.*\:/,"") | |
gsub(/\]$/,"") | |
filename=$0 | |
getline | |
sub(/.*-A/, "") | |
app=$1 | |
concurrency=$2 | |
queue=$3 | |
timelimit=$6 | |
sub(/[^"]+"/, "") | |
sub(/".*$/, "") | |
gsub(/_/, " ") | |
title=$0 | |
print "# -----------------------------------------------" | |
print "- filename: " filename | |
print " title: " title | |
print " queues:" | |
print " - " queue | |
print " app: " app | |
print " concurrency: \"" concurrency "\"" | |
print " time_limit: " timelimit | |
} | |
' \ | |
| gsed "s/{{_/{{ /g" \ | |
| gsed "s/_}}/ }}/g" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment