Molecule converge fails : When hosts is all

472 views
Skip to first unread message

Anushka hasini

unread,
Feb 28, 2022, 3:13:31 PM2/28/22
to Ansible Project
Hi,

I have tried to run molecule test for my Ansible role which contains install iptable dependencies. If I set hosts: localhost in converge.yml it is working fine. But if I give hosts: all throwing below error. I am using docker driver with ubuntu 18.04 installed on it to run my test. 

TASK [twmn.twmn.iptable : Install dependencies] ********************************
[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [instance]: FAILED! => {"changed": false, "cmd": "apt-get update", "msg": "[Errno 2] No such file or directory: b'apt-get': b'apt-get'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

Anyhelp will be appreciable.

Thanks
selvi

Dick Visser

unread,
Mar 1, 2022, 2:12:56 AM3/1/22
to ansible...@googlegroups.com
We need more info that this. 
What does the task file look like?
Etc

--
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/81c08414-b859-4bee-8d95-7932c7269880n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Anushka hasini

unread,
Mar 1, 2022, 3:14:55 AM3/1/22
to ansible...@googlegroups.com
Tasks contain install iptable, iptable-persistent dependencies on ubuntu18.04.

Anushka hasini

unread,
Mar 1, 2022, 3:21:32 AM3/1/22
to ansible...@googlegroups.com
This is my install.yml 

---
- name: Install dependencies
apt:
name: "{{ packages }}"
vars:
packages:
- iptables
- iptables-persistent ---------------------------- rules.yml
---
- block:
- name: Alias port
iptables:
table: nat
chain: PREROUTING
in_interface: "{{ ansible_default_ipv4.interface }}"
protocol: "{{ item.protocol }}"
destination: "{{ item.destination }}"
# destination: "{{ interfaces.0.private_ip_real }}"
destination_port: "{{ item.original_port }}"
jump: DNAT
to_destination: "{{ item.destination }}:{{ item.new_port }}"
# to_destination: "{{ interfaces.0.private_ip_real }}:{{ item.dest_port }}"
comment: "{{ item.comment }}"
notify: iptables-save-rules
loop: "{{ iptables_port_aliases }}"
- name: Masquerade traffic
iptables:
table: nat
chain: POSTROUTING
protocol: '{{ item.protocol | d(omit) }}'
destination: '{{ item.destination }}'
destination_port: "{{ item.destination_port | d(omit) }}"
source: "{{ item.source | d(omit) }}"
source_port: "{{ item.source_port | d(omit) }}"
jump: MASQUERADE
comment: '{{ item.comment }}'
notify: iptables-save-rules
loop: "{{ iptables_masquerade }}"
when: ansible_os_family != 'Windows'
----------------------------- -------------------------------- This is my converge.yml
---
- name: Converge
hosts: localhost
gather_facts: true
become: true
vars:
iptables_port_aliases:
- protocol: 'tcp'
destination: '0.0.0.0'
original_port: '80'
new_port: '8080'
comment: 'http_allt_port'
iptables_masquerade:
- destination: '0.0.0.0'
comment: 'http_allt_port'
tasks:
- name: "Include iptables"
include_role:
name: "twmn.twmn.iptables"

On Tue, Mar 1, 2022 at 8:12 AM Dick Visser <dick....@geant.org> wrote:
Reply all
Reply to author
Forward
0 new messages