So I have an ansible playbook with some custom python modules in the library folder. Works like a charm however, when I import a separate custom python module inside the python script ansible throws an error “no module named “. When I run the python script directly it can import that separate module without problem.
ansible-playbook:
---
- name: Do ding
connection: local
gather_facts: false
hosts: localhost
tasks:
- name: do the ding
ding:
library/ding.py:
#!/usr/bin/env python3
from dong import myperfextprintsolution
def main():
myperfextprintsolution("printsomething")
if __name__ == '__main__':
main()
library/dong.py:
#!/usr/bin/env python3
def myperfextprintsolution(myvariable):
print(myvariable)
return
I know I don’t provide module_stdin od module_stdout so it will give an error anyway but it’s about the “no module named ‘dong’n”. I also added the library path to ansible.cfg
library = ~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:./library
but that doesn’t help much. Any ideas ?
kniebe schermer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.