Skip to content

Instantly share code, notes, and snippets.

@gjuric
Created November 20, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gjuric/85e853fd1db8263add01 to your computer and use it in GitHub Desktop.
Save gjuric/85e853fd1db8263add01 to your computer and use it in GitHub Desktop.
Ansible escaping problem
This works when I run it manualy from the shell:
/bin/echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'pass')" | /usr/bin/graphite-manage shell
This is what I tried to do in Ansible:
- name: test
command: >
/bin/echo "from django.contrib.auth.models import User; User.objects.create_superuser('{{graphite_admin_username}}', '{{graphite_admin_email}}', '{{graphite_admin_password}}')" | /usr/bin/graphite-manage shell
And this is the output from Ansible:
changed: [graphite] => {"changed": true, "cmd": ["/bin/echo", "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'password')", "|", "/usr/bin/graphite-manage", "shell"], "delta": "0:00:00.005750", "end": "2015-11-20 06:51:06.479436", "rc": 0, "start": "2015-11-20 06:51:06.473686", "stderr": "", "stdout": "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'password') | /usr/bin/graphite-manage shell"}
But it does not achieve a desired result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment