# help debugging calling import\_playbook

**URL:** <https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410>\
**Category:** Ansible Project\
**Created:** [June 25, 2021, 10:52am UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410 "2021-06-25T10:52:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![need\_abettername](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@need\_abettername](https://forum.ansible.com/u/need_abettername)\
**Post date:** [June 25, 2021, 10:52am UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410/1 "2021-06-25T10:52:23Z")

</div>

I need help getting more information on why an import\_ playbook fails please…

During a play (play 1) I’m (ansible.builtin.template) sucessfully templating out another play (play 2) and variables file and using trying to call them later in play 1, but that import fails

import\_playbook: $LINUX\_PLAYBOOKS/paperless/{{play\_filename}}  
but I get

fatal: [nott]: FAILED! =\> changed=false  
module\_stderr: |-  
Shared connection to nott.mont closed.  
module\_stdout: “”  
msg: |-  
MODULE FAILURE  
See stdout/stderr for the exact error  
rc: 0

Using debugger: on failed or register and debug var doesn’t give any more useful information

ok: [nott] =\>  
playoutput:  
changed: false  
failed: true  
module\_stderr: |-  
Shared connection to nott.mont closed.  
module\_stdout: “”  
msg: |-  
MODULE FAILURE  
See stdout/stderr for the exact error  
rc: 0

Worth noting that the subject of play1 and play2 is, in this case, the server itself, though the play is intended to be used on other machines as well.

Running play2 directly works ok

running play1 with -vvvvv does show a broken pipe in the ssh commands but I can certainly ssh into the server from itself and play1 works successfully up to the point of that import\_playbook

debug1: auto-mux: Trying existing master  
debug2: fd 3 setting O\_NONBLOCK  
debug2: mux\_client\_hello\_exchange: master version 4  
debug3: mux\_client\_forwards: request forwardings: 0 local, 0 remote  
debug3: mux\_client\_request\_session: entering  
debug3: mux\_client\_request\_alive: entering  
debug3: mux\_client\_request\_alive: done pid = 72692  
debug3: mux\_client\_request\_session: session request sent  
debug1: mux\_client\_request\_session: master session id: 2  
debug3: mux\_client\_read\_packet: read header failed: Broken pipe  
debug2: Received exit status from master 0  
Shared connection to nott.mont closed.  
module\_stdout: “”  
msg: |-  
MODULE FAILURE  
See stdout/stderr for the exact error  
rc: 0  
…ignoring

This fails even if the previous files exist so I don’t think it’s that - I’ve confirmed so the files exist on disk and it’s the same result whether the play is run either with those files existing, or not.

I’ve tried meta reset connection just before this

Appreciate this may not be the best way to do this but I’m interested to see what’s going on now and what I’m missing.

Scratching my head, apologies if this isn’t clear - finding it hard to explain this one

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 25, 2021, 2:18pm UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410/2 "2021-06-25T14:18:06Z")

</div>

The import would not fail with connection issues, no connection is  
involved, what is failing is a task, but you are not providing enough  
output to determine which task it is.

---

<div class="post-metadata">

**Author:** ![need\_abettername](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@need\_abettername](https://forum.ansible.com/u/need_abettername)\
**Post date:** [June 25, 2021, 9:19pm UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410/3 "2021-06-25T21:19:05Z")

</div>

Thanks Brian

Not quite sure I understand, it’s the output I’m trying to get (more of) to understand why it’s failing.

In case it helps at all

Here’s the play 2 created that it fails on. This is fine to run directly through ansible-playbook, just not through that play1

- hosts: nott  
become: yes  
vars\_files:
- /$LINUX\_PLAYBOOKS/paperless/mont\_nott\_vars.yml  
tasks:  
roles:

# - geerlingguy.postgresql

- paperless-ng

# - geerlingguy.nginx

Here’s the section of play 1

# post\_tasks:

- name: run the play - $LINUX\_PLAYBOOKS/paperless/{{play\_filename}}  
import\_playbook: $LINUX\_PLAYBOOKS/paperless/{{play\_filename}}  
register: playoutput  
ignore\_errors: yes

# delegate\_to: 127.0.0.1

become: yes

# debugger: on\_failed

- name: get debug output  
debug:  
var: playoutput

Does that help, or is there something else I can run to get more detail from that mysterious " See stdout/stderr for the exact error"  
That’s what the debug var playoutput should provide isn’t it ??

---

<div class="post-metadata">

**Author:** ![need\_abettername](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@need\_abettername](https://forum.ansible.com/u/need_abettername)\
**Post date:** [June 26, 2021, 8:54am UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410/4 "2021-06-26T08:54:37Z")

</div>

Perhpas I have a misunderstanding here

When you say " no connection is involved"

If I’m right it is possible to ssh from a server to itself - shown by a new shell and the ability to exit back to the previous shell - or am I mistaken and it’s somehow ignoring that

Is this not what ansible is doing if you run a playbook on the same server (without delegate\_to or local connection)?

That would seem to be what’s happening from the ssh output (broken pipe) but I may be completely turned around in my understanding here (?)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 29, 2021, 1:45pm UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410/5 "2021-06-29T13:45:21Z")

</div>

When I say 'no connection is involved' it is in the act of importing a  
playbook, this is a 'LOCAL ACTION' that has nothing to do with a  
remote, so if it fails it will not give a connection error.

One of many issues with your play is that you are trying to import a  
playbook inside a play, this does not work and you should get a  
specific error message, your connection issue might be making the play  
fail before you get there and that is another problem, but again, not  
enough info to debug with. You also cannot register the result of an  
import or include nor ignore import errors.

Also, you cannot use env vars like this $LINUX\_PLAYBOOKS, use the 'env' lookup

---

<div class="post-metadata">

**Author:** ![need\_abettername](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@need\_abettername](https://forum.ansible.com/u/need_abettername)\
**Post date:** [June 30, 2021, 2:20pm UTC](https://forum.ansible.com/t/help-debugging-calling-import-playbook/35410/6 "2021-06-30T14:20:05Z")

</div>

OK, thanks Brian, that gives me some things to go on and I’m clearly in need of going back and starting again to avoid this spaghetti.

Didn’t know about the env variable rather than using those paths so will go that route and that alone has been very helpful.

Thanks for your patience, just learning.
