Re: Failed : Testing IPtables rules with Molecules

95 views
Skip to first unread message

Anushka hasini

unread,
Feb 24, 2022, 7:22:29 AM2/24/22
to Ansible Project
Hi,

I have created iptables ansible roles, which contain rules such as Alias port and Masquerade traffic. I am using molecule to test this role. But whenever I give empty values for those rules, it is working fine. In the scenario, if I pass value to the variables assigned to those rules. I am getting different types of errors. I am testing with docker drivers. For eg., if I give molecule converge 
 
Output look like this
----------------------------------------------------------------------------------------------------------------

TASK [twmn.twmn.iptables : Alias port] *****************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'interfaces' is undefined\n\nThe error appears to be in '/home/hasinianu1217/twmn/ansible/collections/ansible_collections/twmn/twmn/roles/iptables/tasks/rules.yml': line 4, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- block:\n    - name: Alias port\n      ^ here\n"}


CRITICAL Ansible return code was 2, command was: ['ansible-playbook', '--inventory', '/home/hasinianu1217/.cache/molecule/iptables/default/inventory', '--skip-tags', 'molecule-notest,notest', '/home/hasinianu1217/twmn/ansible/collections/ansible_collections/twmn/twmn/roles/iptables/molecule/default/converge.yml']
---------------------------------------------------------------------------------------------------------------------------------
Can anyone clarify me, what is this error look like?

Thanks
Selvi

Abhijeet Kasurde

unread,
Feb 24, 2022, 7:36:48 AM2/24/22
to ansible...@googlegroups.com
Hi Selvi,

Can you please provide content of `/twmn/ansible/collections/ansible_collections/twmn/twmn/roles/iptables/tasks/rules.yml` ? The error suggests that you have not defined `interfaces` variable which is required. It is difficult to answer your question without looking at the role.

Thanks,
Abhijeet

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d4e9eb7c-23bc-4c1d-aaa5-3b110ceecba1n%40googlegroups.com.


--
Thanks,
Abhijeet Kasurde

Anushka hasini

unread,
Feb 27, 2022, 7:04:32 AM2/27/22
to Ansible Project
Hey Abijeet,

Thanks for your reply. Now, I have resolved those issues. But I am still looking for information about how to write test cases in molecule to test the tables alias port and masquerade rules. Molecule converge is working fine, is it possible to do verify those scenarios in  Test infra.

Thanks
Selvi

Reply all
Reply to author
Forward
0 new messages