Comments (12)
Nevermind. I didn't realize that the module wrappers in library/
were what properly call and exit the actual modules in module_utils
. Placing the library/
folder in the top level of my project folder caused ansible to use the proper wrapper module from library/
so that it operated correctly.
I might suggest renaming the modules in module_utils/network/pfsense
and changing the associated imports in library/
wrappers so that they don't have the same names as the wrappers that the user interacts with. That way, ansible doesn't accidentally call the module_utils
file directly resulting in an improper exit I mentioned above.
from ansible-pfsense.
I'm not sure to understand well your issue.
At first, you have copied our files into your ansible installation ?
from ansible-pfsense.
Yes I did.
First, I copied module_utils/network/pfsense
into /usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/
When I reference pfsense_interface
or any other pfsense_*
module from this project, ansible looks in /usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/pfsense
for the module matching that name.
When I tried to run pfsense_interface
from a playbook, it tried executing /usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/pfsense/pfsense_interface.py
but I got the error "msg": "New-style module did not handle its own exit"
.
It wasn't clear to me that I needed to copy library
into my local directory so that ansible would use
./library/pfsense_interface.py
instead of
/usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/pfsense/pfsense_interface.py
which is necessary because
./library/pfsense_interface.py
properly instantiates PFSenseInterfaceModule
and properly exits with exit_json()
when it gets called with pfmodule.commit_changes()
I'm simply saying it's an easy mistake to make since both files are named pfsense_interface.py
and both would be included in ansible's module path when executing it even though /usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/pfsense/pfsense_interface.py
isn't supposed to be used directly.
I hope that makes some sense. I can try to clarify more if you want me to.
from ansible-pfsense.
Ok.
In my opinion, you should install all our files in one place, either in your local directory, either in your ansible installation.
The best would be your local installation.
If for any reason you prefer to use your ansible installation, we have wrote a script that copy all required files into the ansible directory (just run ./misc/local2ansible). It was written because we need to have our files into ansible to use their testing and linting tools.
Could you check there is not a pfsense/networking directory that would still be around in your directories ? (we had to rename it to pfsense/network at a time, and it may explain your issue)
Please let me know if you choose to use your ansible directory, so that I manage files/directories renaming in the install script.
from ansible-pfsense.
so I took a look at /misc/local2ansible
and there are two lines that confuse me
cp module_utils/network/pfsense/*.py ${ANSIBLE_HOME}/lib/ansible/module_utils/network/pfsense/
cp library/*.py ${ANSIBLE_HOME}/lib/ansible/modules/network/pfsense/
It confuses me because there files in module_utils/network/pfsense/
and library/
that are named the same thing so running this script would result in files being copied and then immediately overwritten such as
- pfsense_haproxy_backend.py
- pfsense_haproxy_backend_server.py
- pfsense_interface.py
- pfsense_ipsec.py
- pfsense_ipsec_p2.py
- pfsense_ipsec_proposal.py
- pfsense_nat_outbound.py
- pfsense_nat_port_forward.py
- pfsense_rule.py
- pfsense_vlan.py
So the only way I can get this repo to work correctly is to copy library/
into whatever folder I'm working on and then copy the contents of ./module_utils/network/pfsense
into /usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/pfsense/
Doing that will make ansible use ./library/pfsense_*
modules when calling them from my playbook and then those files in ./library/pfsense_*
can properly import the classes from the python library files I copied into /usr/local/lib/python3.6/dist-packages/ansible/module_utils/network/pfsense/
with lines such as
from ansible.module_utils.network.pfsense.pfsense_interface import PFSenseInterfaceModule, INTERFACE_ARGUMENT_SPEC, INTERFACE_REQUIRED_IF
found in ./library/pfsense_interface.py`
from ansible-pfsense.
You're making a mistake. The two target directories are differents and have different purpose:
${ANSIBLE_HOME}/lib/ansible/module_utils/network/pfsense/
${ANSIBLE_HOME}/lib/ansible/modules/network/pfsense/
The first one is for imports needed by the modules.
The second one is for the modules themself.
from ansible-pfsense.
I must've misread it, I'll try again tomorrow and let you know.
from ansible-pfsense.
Do you have an example of what ${ANSIBLE_HOME}
should be?
I cannot find the expected file layout anywhere in ansible 2.9.2. I guessed that ANSIBLE_HOME
should've been in /usr/local/lib/python3.6/dist-packages/ansible
but running find . | grep lib/
to try to find the lib
folder that local2ansible
copies the files into shows no directory existing named lib
from ansible-pfsense.
It was designed to install our files into the source folder.
I did what was required in the last commit to detect the right path and to do the install there.
from ansible-pfsense.
FWIW - I think it probably does make sense to rename the pfsense_* files/classes in module_utils by removing the "pfsense_" prefix.
from ansible-pfsense.
I dont have any opinion on this so sure, why not ? :)
from ansible-pfsense.
I think merging #38 means this is good to close?
from ansible-pfsense.
Related Issues (20)
- Calling the plugin breaks special XML fields which use CDATA and contain ampersands HOT 4
- Managing DHCP and unbound - any plans? HOT 4
- Modules list error in main README.md ? HOT 1
- Feature Request: Provide interface update HOT 1
- Ansible - Error using privilege escalation HOT 1
- pfsense 2.5 Support? HOT 25
- using ca module in pfsense 2.5 HOT 1
- pfsensible.core not compatible with ansible.netcommon 2.0.0 HOT 1
- diff['before'] is equal to diff['after'] HOT 1
- Retire this repo HOT 5
- pfsense_vlan.py error on 2.5.1 HOT 5
- Problem with pfsense_authserver_ldap module - automatically change LDAP config ? HOT 2
- pfsense_ipsec_p2 module overwriting other p2 interfaces in 2.5.2 HOT 1
- pfsense_aggregate: module failuer when try to use non-default gateway with the rule
- cannot add vlan interface HOT 1
- can we have a backup option on this ansible modules HOT 1
- Rule add issue when alias list is empty -> TypeError: 'NoneType' object is not iterable HOT 1
- pfsense_interface module cannot remove a subinterface HOT 1
- ERROR! 'pfsense_rule' is not a valid attribute for a Play HOT 1
- Not a problem - just wondering if there is a way to print a list of users by group? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-pfsense.