q
q copied to clipboard
Not any file named q
Hi
using q in an ansible module as follows:
def exec_module(self):
changed = False
result = dict()
state = self.want.state
import q
q.q(state)
There is no file q created anywhere in the file system...
[root@ansible-tower-32 library]# find / -type f -name q -print | wc -l
0
I reckon this is a problem between the chair and the keyboard.... any tip would be more than welcome
Thanks!
Ulises
q.py[co]
@jhermann I don't know what you mean....
In any case, if I do the following simple test it does work from outside Ansible Tower
[root@ansible-tower-32 library]# python
Python 2.7.5 (default, Feb 20 2018, 09:19:12)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import q
>>> something = "test"
>>> q.q(something)
'test'
>>>
[root@ansible-tower-32 library]# ls -l /tmp/q
-rw-r--r--. 1 root root 42 Apr 24 08:56 /tmp/q
[root@ansible-tower-32 library]# cat /tmp/q
15.0s <module>: 'test'
try decorating def exec_module with q to see if it's even called.
@alonsocamaro did you get this to work in the end? I'm trying to use q to trace an ansible module, and so far it's just adding to the confusion.
Adding @q decorator to all the module's internal methods seems to result in /tmp/q just listing them all. Using @q.t gives the expected parameters etc in the file, but only for some calls (I can see from behaviour that some of the trace functions are being called but not logged).
I really want this to work - debugging ansible is horrible!
(so, for the @q case, I get something like this, which is just a list of all the functions in the module - there is no code path that will actually run them in this order)
0.2s AzureRMEventGridSubscription:
<function AzureRMEventGridSubscription.exec_module>
0.2s AzureRMEventGridSubscription:
<function AzureRMEventGridSubscription.get_eventgrid_client>
0.2s AzureRMEventGridSubscription:
<function AzureRMEventGridSubscription.get_subscription>
0.2s AzureRMEventGridSubscription:
<function AzureRMEventGridSubscription.create_update_subscription>
0.2s AzureRMEventGridSubscription:
<function AzureRMEventGridSubscription.delete_subscription>
I have run into the same problem while trying to debug build backends and I suspect we have the same problem: q respects tempfile.gettmpdir() which for instance in the project I'm working on looks like this:
>>> import tempfile; tempfile.gettempdir()
'/var/folders/7f/5bq0ctcs4tl_7k2721s0ycy80000gn/T'
It would be nice if I could overwrite that with something like Q_FORCE_FILE=/tmp/q.
It would be nice if I could overwrite that with something like
Q_FORCE_FILE=/tmp/q.
Did you try explicitly setting TMPDIR? Maybe the code that uses that does the right thing?
I confirm explicit setting of TMPDIR works well. On my computer with macOS 13.6, I had just to execute :
export TMPDIR=/tmp
And now I have q() output in /tmp/q