Reputation: 15
- name: Migrate graphite settings
command:
argv:
- PYTHONPATH=/opt/graphite/webapp/
- django-admin
- migrate
- --settings=graphite.settings
ignore_errors: yes
Is producing:
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "PYTHONPATH=/opt/graphite/webapp/ django-admin migrate --settings=graphite.settings", "msg": "[Errno 2] No such file or directory: b'PYTHONPATH=/opt/graphite/webapp/'", "rc": 2}
I think Ansible is reading PYTHONPATH as a file or directory. Which it isn't. How can I get a command to treat PYTHONPATH= as just setting the PYTHONPATH value for a command?
Upvotes: 0
Views: 401
Reputation: 33203
There are two options, one more ansible-y than the other:
The ansible way is environment:
as in
- name: Migrate graphite settings
environment:
PYTHONPATH: /opt/graphite/webapp/
command:
argv:
- django-admin
- migrate
- --settings=graphite.settings
ignore_errors: yes
and the other is to use the env
command such that becomes something that can be executed; that SOME_VAR=some-value some_command
syntax is a shell construct, and thus can only be used with shell:
or by explicitly wrapping argv in a [sh, -c]
which would defeat the purpose of command:
- name: Migrate graphite settings
command:
argv:
- env
- PYTHONPATH=/opt/graphite/webapp/
- django-admin
- migrate
- --settings=graphite.settings
ignore_errors: yes
Upvotes: 1