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 <[email protected]> wrote:
> We need more info that this.
> What does the task file look like?
> Etc
>
> On Mon, 28 Feb 2022 at 21:13, Anushka hasini <[email protected]>
> wrote:
>
>> 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
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/81c08414-b859-4bee-8d95-7932c7269880n%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/81c08414-b859-4bee-8d95-7932c7269880n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwN3dW9KNNMLpddtjh4i0DJp8synTCdbS%3DdqBQ%2BD_WJU2A%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwN3dW9KNNMLpddtjh4i0DJp8synTCdbS%3DdqBQ%2BD_WJU2A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAOfiCBpXR1fkQyDkir6axW3JWrFDy9p358uNYLhmOfgWYJseXw%40mail.gmail.com.